mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
Re-apply #2125 (reverted in #2130) to preserve `disabled` attribute. Carbon styles depend on the `[disabled]` attribute. However, the `disabled` attribute is not valid markup when applied to `div role="option"`. This PR preserves the existing `disabled` attribute while also setting `aria-disabled` to maintain accessibility.
This commit is contained in:
parent
43511e09ec
commit
9b61af0306
2 changed files with 2 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
||||||
class:bx--list-box__menu-item--active={active}
|
class:bx--list-box__menu-item--active={active}
|
||||||
class:bx--list-box__menu-item--highlighted={highlighted || active}
|
class:bx--list-box__menu-item--highlighted={highlighted || active}
|
||||||
aria-selected={active}
|
aria-selected={active}
|
||||||
|
aria-disabled={disabled ? true : undefined}
|
||||||
disabled={disabled ? true : undefined}
|
disabled={disabled ? true : undefined}
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
on:click
|
on:click
|
||||||
|
|
|
@ -166,6 +166,7 @@ describe("ComboBox", () => {
|
||||||
const disabledOption = screen.getByText(/Fax/).closest('[role="option"]');
|
const disabledOption = screen.getByText(/Fax/).closest('[role="option"]');
|
||||||
assert(disabledOption);
|
assert(disabledOption);
|
||||||
expect(disabledOption).toHaveAttribute("disabled", "true");
|
expect(disabledOption).toHaveAttribute("disabled", "true");
|
||||||
|
expect(disabledOption).toHaveAttribute("aria-disabled", "true");
|
||||||
|
|
||||||
await user.click(disabledOption);
|
await user.click(disabledOption);
|
||||||
expect(screen.getByRole("textbox")).toHaveValue("");
|
expect(screen.getByRole("textbox")).toHaveValue("");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue