palantir/blueprint

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

开放

#6,028 创建于 2023年3月17日

 (0 条评论) (1 个反应) (0 位负责人)TypeScript (2,167 个派生)batch import
P2Package: coreType: bughelp wanted

仓库指标

星标
 (20,263 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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.

贡献者指南