Skip to content

Activate the file upload button on Space and NumpadEnter - #40

Merged
rmuratov merged 1 commit into
mainfrom
file-upload-keyboard-activation
Jul 12, 2026
Merged

Activate the file upload button on Space and NumpadEnter#40
rmuratov merged 1 commit into
mainfrom
file-upload-keyboard-activation

Conversation

@rmuratov

Copy link
Copy Markdown
Owner

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 different code, so both were ignored.

Fix

The handler now checks event.key === 'Enter' || event.key === ' ': key (unlike code) is 'Enter' for NumpadEnter too, and Space is handled with preventDefault() 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 needs ref.current?.click() whose null branch 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 main without the fix (verified via git stash).

Coverage stays at 100%.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (df741b3) to head (a73244c).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rmuratov
rmuratov merged commit 1f5efa9 into main Jul 12, 2026
3 of 4 checks passed
@rmuratov
rmuratov deleted the file-upload-keyboard-activation branch July 12, 2026 08:50
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.

File upload button: keyboard activation misses Space and NumpadEnter

1 participant