Skip to content

onBlur in EditCell is not fired after implementing mouse down event to select cell #3797

@naoki-tateyama

Description

@naoki-tateyama

Describe the bug

After commit 7b8a205 (introduced in PR #3774), onBlur in EditCell no longer fires if the user finishes editing by clicking on another cell.

To Reproduce

  1. In src/editors/textEditor.ts, add console.log('onBlur') in onBlur.
onBlur={() => {
  console.log('onBlur');
  onClose(true, false);
}}
  1. Start the dev server, open the AllFeatures example, double-click any First name cell to enter edit mode, then click a different cell.

Expected behavior

'onBlur' should be printed in the console.

Link to Minimal Reproducible Example

Environment

  • react-data-grid version: beta.55
  • react/react-dom version:

Additional context

#3774 changed the way to capture the selecting cell.
After this PR, the onBlur is not called anymore.

  1. The mouse down event in another cell is called to change the selectedPosition.
  2. getCellEditor in DataGrid returns undefined because of selectedPosition.mode === 'SELECT'. This early return causes unmount of EditCell before onBlur.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions