palantir/blueprint

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

Open

#6,028 建立於 2023年3月17日

在 GitHub 查看
 (0 留言) (1 反應) (0 負責人)TypeScript (20,263 star) (2,167 fork)batch import
P2Package: coreType: bughelp wanted

描述

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.

貢獻者指南