palantir/blueprint

useHotkeys stopPropagation is called on the native event instead of the synthetic one

Open

#6028 opened on Mar 17, 2023

View on GitHub
 (0 comments) (1 reaction) (0 assignees)TypeScript (20,263 stars) (2,167 forks)batch import
P2Package: coreType: bughelp wanted

Description

Environment

  • Package version(s): 4.17.6
  • Operating System: 13.2.1 (22D68)
  • Browser name and version: Version 111.0.5563.64 (Official Build) (arm64)

Code Sandbox

Link to a minimal repro: https://codesandbox.io/s/serverless-rgb-cmsi5j

Steps to reproduce

  1. Focus the input group.
  2. Press w.
  3. Look at the console and notice how the parent component's onKeyDown handler is still called despite setting stopPropagation: true on the hotkey.

Actual behavior

The parent onKeyDown handler was called.

Expected behavior

The parent onKeyDown handler shouldn't have been called.

Possible solution

stopPropagation should be called on React's synthetic event instead of the browser's native one because React uses event delegation and registers all handlers on the root node. Issue can be found here.

Contributor guide