-
Notifications
You must be signed in to change notification settings - Fork 21
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
cc-button: focus is lost when set to disabled
#1124
Closed
2 of 3 tasks
Comments
florian-sanders-cc
added
bug
Something isn't working
a11y
Related to accessibility
labels
Jul 23, 2024
2 tasks
We also have the problem on
|
@pdesoyres-cc nice catch, it makes sense that we have the same issue with other form elements (should only happen with form elements because that's the only place Let's discuss this next week? |
4 tasks
florian-sanders-cc
added a commit
that referenced
this issue
Jan 14, 2025
These properties are mutually exclusive and should not be set to `true` at the same time to avoid a11y issues. Fixes #1124
florian-sanders-cc
added a commit
that referenced
this issue
Jan 14, 2025
…t the same time Fixes #1124
florian-sanders-cc
added a commit
that referenced
this issue
Jan 14, 2025
…ing` at the same time Fixes #1124
florian-sanders-cc
added a commit
that referenced
this issue
Jan 14, 2025
… the same time Fixes #1124
florian-sanders-cc
added a commit
that referenced
this issue
Jan 14, 2025
…at the same time Fixes #1124
florian-sanders-cc
added a commit
that referenced
this issue
Jan 14, 2025
…at the same time Fixes #1124
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Context
We have decided that the native button within the
<cc-button>
component should remain focusable while the component isdisabled
.This is done by using
aria-disabled
instead ofdisabled
on the<button>
element.Unfortunately, Chrome considers the focus to be lost as soon as we set the component to
disabled
.This seems to be caused by a clash with the native
disabled
attribute / prop.Even though Chrome should not do that, we should change the attribute / prop and we should enforce never using native attributes as props for our components (see # TODO edit to link to the separate issue).
Edit: the issue is only present when dealing with
formAssociated
components as you can see with this minimal reproduction (https://jsbin.com/munohafoqa/1/edit?html,css,js,output).It does make sense because
formAssociated
elements are recognized as actual form elements and chrome removes focus from disabled elements (this is why we have decided not to disable the native<button>
element within the component and usearia-disable
instead).Moving away from
disabled
attributes means that disabled custom elements will now participate in forms and_internals.willValidate()
will betrue
.We could remove form data entries when a component is disabled
_internals.setFormValue(null)
but this is not great + we would need to change whatwillValidate
exposes (instead of directly exposing_internals.willValidate
, we would have to expose whether it's disabled or willValidate. All of this is not great because the abstract class that handles form controls does not know of thedisabled
(orisDisabled
property).Decision & TODO
cc-button
add a console.error()when both
disabledand
waiting` are used at the same time,disabled
andwaiting
are used at the same time,The text was updated successfully, but these errors were encountered: