palantir/blueprint

Editable Cell with enableFocusedCell stealing focus

Open

#4,796 建立於 2021年7月2日

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

描述

Environment

Package version(s): @blueprintjs/table 3.7.1 Operating System: MacOS Catalina 10.15.7 Browser name and version: Chrome Version 91.0.4472.114

Code Sandbox

https://codesandbox.io/s/enablefocusedcell-bug-0m19u

Steps to reproduce

  1. Enter a value into any cell (do not do anything to confirm the value ie press enter)
  2. Click the red div (or anywhere outside the table...thus confirming the cell)
  3. press any key
  4. See the cell listens for the keypress

Actual behavior

Although there has been an interaction outside of the table, the cell is still the active element (see console) and steals the next keypress.

Expected behavior

I would expect once there has been a user interaction outside the table, the cell should not listen for keypresses.

Possible solution

I believe the focus is being forced by this function which runs on every render https://github.com/palantir/blueprint/blob/5c05ce6bb12a9810b9ff35310a1554a65af6b65d/packages/table/src/cell/editableCell.tsx#L214-L219

貢獻者指南