You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat!: use role attribute instead of native button - #2394
There are 2 approaches suggested by Tetralogical (#132) on how to organize the HTML structure of the button so that it would become more accessible for screen readers.
1st approach (prototyped and currently used in @vaadin/button):
The approach is based on the native <button> element.
<vaadin-buttonpart="vaadin-login-submit" theme="primary contained">
# shadow-root
<buttonclass="vaadin-button-container"><spanpart="prefix"><slotname="prefix"></slot></span><spanpart="label"><slot></slot></span><spanpart="suffix"><slotname="suffix"></slot></span></button>
# end shadow-root
Log in
</vaadin-button>
2nd approach:
The approach is based on the [tabindex=0] and [role=button] attributes which should be set on the button host.
<vaadin-buttonpart="vaadin-login-submit" theme="primary contained" tabindex="0" role="button">
# shadow-root
<divclass="vaadin-button-container"><divpart="prefix"><slotname="prefix"></slot></div><divpart="label"><slot></slot></div><divpart="suffix"><slotname="suffix"></slot></div></div>
# end shadow-root
Log in
</vaadin-button>
While the current implementation of the button is based on the 1st approach (with the native button), this approach supposes us to make some changes in the Lumo and Material themes (moving padding from the host on the native button in particular) in order to adjust them for the new HTML structure.
The 2nd approach, on the other hand, doesn't suppose any changes in the themes and also allows us to get rid of ControlStateMixin in favor of the modern TabIndexMixin, FocusMixin.
The 2nd approach also provides a more convenient HTML structure that makes easier the future removal of the <span> wrappers, see #955 (comment).
This PR aims at giving an implementation for the 2nd approach as it has been considered to be more advantageous.
I have added a description following the guideline.
The issue is created in the corresponding repository and I have referenced it.
I have added tests to ensure my change is effective and works as intended.
New and existing tests are passing locally with my change.
I have performed self-review and corrected misspellings.
Additional for Feature type of change
Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.
vursen
changed the title
feat: use FocusMixin and TabindexMixin for the new button
feat: use FocusMixin and TabindexMixin for new button
Aug 26, 2021
vursen
changed the title
feat: use FocusMixin and TabindexMixin for new button
feat: improve button accessibility removing native button in favor of role attribute
Aug 26, 2021
vursen
changed the title
feat: improve button accessibility removing native button in favor of role attribute
feat: remove native button in favor of role attribute
Aug 26, 2021
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
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.
Introduction
There are 2 approaches suggested by Tetralogical (#132) on how to organize the HTML structure of the button so that it would become more accessible for screen readers.
1st approach (prototyped and currently used in
@vaadin/button):The approach is based on the native
<button>element.2nd approach:
The approach is based on the
[tabindex=0]and[role=button]attributes which should be set on the button host.While the current implementation of the button is based on the 1st approach (with the native button), this approach supposes us to make some changes in the Lumo and Material themes (moving
paddingfrom the host on the native button in particular) in order to adjust them for the new HTML structure.The 2nd approach, on the other hand, doesn't suppose any changes in the themes and also allows us to get rid of
ControlStateMixinin favor of the modernTabIndexMixin,FocusMixin.The 2nd approach also provides a more convenient HTML structure that makes easier the future removal of the
<span>wrappers, see #955 (comment).This PR aims at giving an implementation for the 2nd approach as it has been considered to be more advantageous.
Part of #2224
Related a11y issues
Type of change
Checklist
Additional for
Featuretype of change