feat(data-editor): add keepFocusOnEnterAccept prop#1184
Open
wilsonglasser wants to merge 1 commit into
Open
Conversation
When true, pressing Enter to commit an overlay edit keeps the cursor on the edited cell instead of moving it down. Tab / Shift+Tab / Shift+Enter still move horizontally / upward as usual — only the [0, 1] (Enter → down) movement is neutralized. Default false — preserves the existing 'Enter moves down' behavior so this is backward-compatible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
keepFocusOnEnterAcceptboolean prop toDataEditor. When enabled, pressing Enter to commit an overlay edit keeps the cursor on the edited cell instead of moving it down by one row.The other accept directions are unaffected: Tab, Shift+Tab, and Shift+Enter continue to move horizontally / upward as usual. Only the
[0, 1](Enter → down) movement is neutralized.Motivation
In spreadsheet-style data editors backing real databases, a deliberate Enter generally means "commit this edit" - not "move the cursor down". The default Enter-moves-down behavior makes single-cell edits feel like the cursor is being yanked away after every commit, and it interferes with subsequent arrow-key navigation. This is also the behavior most native editors (Excel-style or otherwise) expose as a configuration option.
Implementation
The change is localized to
onFinishEditinginpackages/core/src/data-editor/data-editor.tsx. WhenkeepFocusOnEnterAcceptistrueand the incomingmovementis exactly[0, 1], we replace it with[0, 0]before the rest of the handler runs - soupdateSelectedCellis never invoked for the Enter case and the cursor / scroll stay put. All other movement vectors flow through unchanged.Backwards compatibility
Default is
false, so existing consumers see no behavior change. Opt-in only.Test plan
keepFocusOnEnterAccept={true}.keepFocusOnEnterAcceptunset orfalse) is identical to today's.