fix(list-box): set aria-disabled if disabled (#2125) (#2138)

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:
Eric Liu 2025-03-23 10:46:25 -07:00 committed by GitHub
commit 9b61af0306
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View file

@ -166,6 +166,7 @@ describe("ComboBox", () => {
const disabledOption = screen.getByText(/Fax/).closest('[role="option"]');
assert(disabledOption);
expect(disabledOption).toHaveAttribute("disabled", "true");
expect(disabledOption).toHaveAttribute("aria-disabled", "true");
await user.click(disabledOption);
expect(screen.getByRole("textbox")).toHaveValue("");