Skip to content

fix(aria/menu): accept a bare disabled attribute on MenuItem - #33965

Open
DuncanFaulkner wants to merge 1 commit into
angular:mainfrom
DuncanFaulkner:fix/aria-menu-item-disabled-attribute
Open

DuncanFaulkner wants to merge 1 commit into
angular:mainfrom
DuncanFaulkner:fix/aria-menu-item-disabled-attribute

Conversation

@DuncanFaulkner

Copy link
Copy Markdown
Contributor

MenuItem.disabled was declared as input<boolean>(false), so <div ngMenuItem disabled> failed strict template type-checking (and was not disabled in JIT). It now uses booleanAttribute, like the disabled inputs on the other aria directives.

Adds a test that a bare disabled attribute sets aria-disabled="true".

Fixes #33964

@crisbeto

Copy link
Copy Markdown
Member

Looks like CI is failing.

MenuItem.disabled was declared as input<boolean>(false), so
<div ngMenuItem disabled> failed strict template type-checking and was
not disabled in JIT. Use booleanAttribute, like the disabled inputs on
the other aria directives.

Fixes angular#33964
@DuncanFaulkner
DuncanFaulkner force-pushed the fix/aria-menu-item-disabled-attribute branch from 4362f94 to 63433c4 Compare October 16, 2026 20:39
@DuncanFaulkner

Copy link
Copy Markdown
Contributor Author

@crisbeto all fixed

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Oct 17, 2026
@ok7sai

ok7sai commented Oct 17, 2026

Copy link
Copy Markdown
Member

This might introduce side effect in some cases. Currently Aria menu items only supports soft-disabled by only setting aria-disabled, but if we allow using boolean attribute disabled, then for elements like <button>, it gets hard-disabled when disabled is applied.

I haven't tested but I think this affects the list-navigation behavior. If a button menu item has set disabled, but internally it's soft-disabled to the list, then I am not sure 1) if the navigation can still puts focus on the disabled menu item, or 2) the focus falls back to the <body> because the menu item can't be focused, and 3) how screen reader reads the result.

@crisbeto crisbeto removed the action: merge The PR is ready for merge by the caretaker label Oct 17, 2026
@crisbeto

Copy link
Copy Markdown
Member

The way we deal with this on Material components that support coercion for disabled is to have an attr.disabled host binding. It doesn't seem like we have that for Aria though.

@ok7sai

ok7sai commented Oct 17, 2026

Copy link
Copy Markdown
Member

The way we deal with this on Material components that support coercion for disabled is to have an attr.disabled host binding. It doesn't seem like we have that for Aria though.

We have in some places like Aria accordion trigger, because it's commonly applied to <button>. Not for the Aria menu item because we assumed soft-disabled is preferred.

Adding [attr.disabled]: 'null' (if want to keep the menu items to always be soft-disabled) would solve that if we don't need to support hard-disabling. Looking at the linked bug I think that's good enough.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: aria/menu target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(aria/menu): MenuItem disabled doesn't accept a bare attribute

3 participants