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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[material-ui][Chip] The skipFocusWhenDisabled prop skips the focus when set to false and when disabled is true #40096

Open
2 tasks done
TLSSter opened this issue Dec 4, 2023 · 7 comments
Assignees
Labels
bug 馃悰 Something doesn't work component: chip This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material

Comments

@TLSSter
Copy link

TLSSter commented Dec 4, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 馃暪

Link to live example:

Steps:

  1. Go to the Mui chip link https://mui.com/material-ui/react-chip/
  2. Goto the clickable section
  3. update the example with the following code
    <Chip label="Clickable" disabled skipFocusWhenDisabled={false} onClick={handleClick} /> <Chip label="Clickable" variant="outlined" onClick={handleClick} />

Current behavior 馃槸

If you inspect the first chip component that is disabled if you set skipFocusWhenDisabled={true} the tabIndex is set to -1 which I think is correct if you then set skipFocusWhenDisabled={false} the tabIndex is still -1 which I think is incorrect.

Expected behavior 馃

When disabled is set to true and skipFocusWhenDisabled={false} the Index should not be -1 it should allow it to have focus.

Context 馃敠

No response

Your environment 馃寧

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@TLSSter TLSSter added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Dec 4, 2023
@TLSSter TLSSter changed the title skipFocusWhenDisabled does not skip the focus when disabled is set. skipFocusWhenDisabled idoes not skip the focus when set to false and when disabled is set to true. Dec 4, 2023
@TLSSter TLSSter changed the title skipFocusWhenDisabled idoes not skip the focus when set to false and when disabled is set to true. skipFocusWhenDisabled does not skip the focus when set to false and when disabled is set to true. Dec 4, 2023
@TLSSter TLSSter changed the title skipFocusWhenDisabled does not skip the focus when set to false and when disabled is set to true. skipFocusWhenDisabled skips the focus when set to false and when disabled is set to true. Dec 4, 2023
@danilo-leal danilo-leal changed the title skipFocusWhenDisabled skips the focus when set to false and when disabled is set to true. [material-ui][Chip] The skipFocusWhenDisabled prop skips the focus when set to false and when disabled is true Dec 4, 2023
@danilo-leal danilo-leal added component: chip This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Dec 4, 2023
@aman44444
Copy link

@danilo-leal i want to work on this issue, can you please assign this to ?

@brijeshb42
Copy link
Contributor

@aman44444 Assigned. Please let us know if you are facing any issues.

@aman44444
Copy link

@brijeshb42 i attempted to change the value of tabIndex both directly and indirectly, but it's not working. after debugging, i discovered that the value only changes when 'disabled' is applied. there is no effect of 'skipFocusWhenDisabled,' and i am sorry I couldn't determine how 'disabled' is changing the value. also sorry for the late reply.

@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented Dec 20, 2023

There's a bug in the skipFocusWhenDisabled prop added in #35065. We overlooked cases where the chip is both clickable and disabled when rendered as ButtonBase.

@ZeeshanTamboli ZeeshanTamboli added bug 馃悰 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Dec 20, 2023
@aacevski
Copy link
Contributor

Hey @ZeeshanTamboli, I want to take on this task but I'm a little confused. Accessibility wise, shouldn't a disabled Chip always have a tabIndex of -1? That is how it is in the ButtonBase component which imo is correct.

I have removed the usage of this prop in my playground and it works as expected, the Chip is not focused, I did this to recreate the issue/PR you have sent. I feel like I'm missing an important piece.

@ZeeshanTamboli
Copy link
Member

@aacevski When the skipFocusWhenDisabled prop is set to false (either as its default value or when not explicitly provided to the component), the disabled Chip should be focusable. Conversely, when set to true, the disabled Chip should be non-focusable. The inclusion of this prop aimed to prevent a breaking change in #35065, as discussed in that thread. However, its current functionality falls short of expectations, working only when a disabled Chip has an onDelete prop, as shown in the example:

<Chip label="Chip Filled" onDelete={() => {}} disabled />

Considering the issues with its implementation, and ideal solution is to consider removing this prop and address #35038 properly, which the PR #35065 attempts to resolve. It's worth noting that such a change would introduce a breaking change.

@aacevski
Copy link
Contributor

Okay thank you @ZeeshanTamboli, I'll try to take on this and update you soon. 馃檶馃徏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 馃悰 Something doesn't work component: chip This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

No branches or pull requests

6 participants