Fix / Accessibility: Focus lost when submitting a form #477
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.
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 thearia-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 nativedisabled
attribute, but thedisabled
attribute makes the button non-focusable/tabbable causing this issue. Strangely enough only for submit-buttons and on Android...Some related articles: