Skip to content

fix: submit inputs on Enter without double-trigger#442

Open
shields wants to merge 4 commits intoNerivec:mainfrom
shields:press-enter
Open

fix: submit inputs on Enter without double-trigger#442
shields wants to merge 4 commits intoNerivec:mainfrom
shields:press-enter

Conversation

@shields
Copy link
Copy Markdown

@shields shields commented Feb 22, 2026

Add onKeyDown handlers to RangeEditor and TextEditor so pressing Enter triggers onChange. Track the last submitted value via a useTrackedValue hook to prevent double-trigger on Enter+blur and skip unnecessary blur submissions when the value hasn't changed.

Previously, RangeEditor and TextEditor only submitted values on blur
(clicking outside). Add onKeyDown handlers so pressing Enter also
triggers the onChange callback.
@Nerivec
Copy link
Copy Markdown
Owner

Nerivec commented Feb 22, 2026

Unless I'm mistaken, this will double-trigger with onBlur (enter then blur = 2x calls).

Track last submitted value with useTrackedValue hook so onChange is
only called when the value actually changed. Prevents double-trigger
when Enter is followed by blur, and skips unnecessary blur submissions
when the value hasn't changed.
@shields shields changed the title fix: submit numeric and text inputs on Enter key press fix: submit inputs on Enter without double-trigger Feb 22, 2026
@shields
Copy link
Copy Markdown
Author

shields commented Feb 22, 2026

Unless I'm mistaken, this will double-trigger with onBlur (enter then blur = 2x calls).

Good catch. There's a related bug in the current code in that if you focus and blur the field, it will submit unnecessarily. Fixed both issues.

@Nerivec
Copy link
Copy Markdown
Owner

Nerivec commented Feb 22, 2026

There's a related bug

Been meaning to fix that one indeed 😁
Let's wait for #443 to be merged (will likely conflict otherwise), then we can rebase this, and fix the bunch of other places where this bug also occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants