Activate the file upload button on Space and NumpadEnter - #40
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #40 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 9
Lines 209 210 +1
Branches 55 55
=========================================
+ Hits 209 210 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Closes #31
Problem
The "Choose files" label acts as a button but its keydown handler only checked
event.code === 'Enter'. Real buttons also activate on Space, and NumpadEnter has a differentcode, so both were ignored.Fix
The handler now checks
event.key === 'Enter' || event.key === ' ':key(unlikecode) is'Enter'for NumpadEnter too, and Space is handled withpreventDefault()so it activates the button instead of scrolling the page.The issue also suggested replacing the pattern with a real
<button>clicking the hidden input via a ref. That variant needsref.current?.click()whosenullbranch is unreachable in tests, which would break the 100% coverage gate for no behavioral gain, so the minimal handler fix won.Tests
The existing keyboard test now covers all four cases: an unrelated key does nothing, Enter, NumpadEnter, and Space all trigger the click, and Space's default is prevented. It fails on
mainwithout the fix (verified viagit stash).Coverage stays at 100%.