Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix / Accessibility: Focus lost when submitting a form #477

Merged
merged 3 commits into from
Apr 3, 2024

Conversation

langemike
Copy link
Collaborator

@langemike langemike commented Mar 27, 2024

When submitting a form, the submit button gets disabled. This causes a bug on the Android screen reader. The button focus is lost and is set to the body-element instead. This causes the page title to be read by the screen reader instead of a potential form error message.

Removing the disabled attribute - while maintaining the aria-disabled attribute - to fix the issue raises the question where the focus should be set when a generic error occurs. This error message is invisible when it's a validation error and visible on any other error. I reasoned to keep it simple: maintain the focus on the submit-button, so the users know where they are in the UI instead of moving the focus to something that we consider the most "relevant" element.

A disabled button should still be able to receive focus and be read by the screen reader. A good example is the "Start Watching" button which can be in a disabled-state for an upcoming live event.

aria-disabled has the same purpose as the native disabled attribute, but the disabled attribute makes the button non-focusable/tabbable causing this issue. Strangely enough only for submit-buttons and on Android...

Some related articles:

@langemike
Copy link
Collaborator Author

langemike commented Apr 2, 2024

@AntonLantukh I get the following error for the deploy preview / lighthouse test
throw new Error(`Input required and not supplied: ${name}`);

Is there something I can do this fix this? I do not understand the cause as it seems unrelated to my minor change.

@ChristiaanScheermeijer
Copy link
Collaborator

^ should be fixed in the next PR because @langemike was not a contributor yet when submitting this PR (GitHub security)

@AntonLantukh AntonLantukh merged commit 0f5c3b5 into jwplayer:develop Apr 3, 2024
8 of 9 checks passed
@langemike langemike deleted the fix/disabled-button-focus branch April 24, 2024 06:53
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.

3 participants