Skip to content

Interactivity API: shiftKey not pressed in pointer events, when keyboard('{Shift>}') is active #7007

@gossi

Description

@gossi

Describe the bug

Happy to switch to the new interactivity API (my code predates that API).

I'm doing a multi-select for a composite aria widget, so when holding down shift key and click an item, it will be selected.

Here is my idea to write the test code, as suggested at testing-library:

const user = userEvent.setup();
await user.keyboard('{Shift>}');
await user.click(thirdItem);
await user.keyboard('{/Shift}');

my code registers a pointerup event, which has this check:

handlePointer(event: PointerEvent, item: Item) {
  if (event.shiftKey) {
    this.selectShift(item);
  }

  // ...
}

but when logging the "click" event, the shiftKey property is set to false.

Reproduction

Currently working on a public PR:

Code:

you might wanna put a console.log()/breakpoint at that function.

Setup:

  • checkout repo above
  • pnpm install
  • cd packages/aria-voyager
  • pnpm test:ui
  • failing test is tests/listbox/navigation/focus/with-multi-selection.test.ts

System Info

System:
    OS: macOS 14.5
    CPU: (11) arm64 Apple M3 Pro
    Memory: 67.67 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.10.0 - ~/.local/share/mise/installs/node/22/bin/node
    npm: 10.9.0 - ~/.local/share/mise/installs/node/22/bin/npm
    pnpm: 9.13.2 - ~/.local/share/mise/installs/node/22/bin/pnpm
    Watchman: 2024.07.08.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 103.1.41.100
    Chrome: 131.0.6778.86
    Edge: 124.0.2478.51
    Safari: 17.5
  npmPackages:
    @vitest/browser: ^2.1.8 => 2.1.8
    @vitest/coverage-istanbul: ^2.1.8 => 2.1.8
    @vitest/ui: ^2.1.8 => 2.1.8
    vite: 5.4.11 => 5.4.11
    vitest: ^2.1.8 => 2.1.8

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat: browserIssues and PRs related to the browser runnerp3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    Status

    Approved

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions