Repository navigation
feat: support arrow keys on range inputs - #1354
Open
sviat-barbutsa wants to merge 1 commit into
Open
sviat-barbutsa wants to merge 1 commit into
sviat-barbutsa wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
What
I added arrow-key support for focused
<input type="range">elements. When a keypress is simulated on one, it moves the slider by one step and dispatchesinput, thenchange, beforekeyup.Pressing
ArrowRightagain at the max of a horizontal left-to-right slider does not fire either event. Cancelingkeydownalso leaves the value untouched.Fixes #1067 and covers the keyboard piece of #871.
Why
Gutenberg's border-width test sets the slider value directly, so I tried the published WordPress
BorderControlin a local React fixture. FourArrowRightpresses moved both the slider and its linked number field from1pxto5pxacross Chrome, Edge, Opera, Firefox, and Safari on macOS.This change matched native input at every step, reporting
2px,3px,4px, and5pxalong the way. Withuser-event14.6.13, the width stayed at1pxand the component received no callbacks. (Gutenberg test)How
step="any": I used the input's native stepping methods for numeric steps, including fractional ones. Forstep="any", the change moves by 1% of the range to match Chrome and Safari (Firefox uses a different increment).50,ArrowRightmoved Chrome to49and Safari18.2to51. Firefox160also firedchangeon the firstArrowRightfor some sliders initialized at their maximum.main. Type-checking, lint, and the build all passed.Checklist