Skip to content

Commit f0e8911

Browse files
committed
feat(aria/menu): Add accessors for pattern properties
1 parent 64f1d43 commit f0e8911

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

src/aria/menu/menu.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ import {DeferredContent, DeferredContentAware} from '@angular/aria/deferred-cont
4444
exportAs: 'ngMenuTrigger',
4545
host: {
4646
'class': 'ng-menu-trigger',
47-
'[attr.tabindex]': '_pattern.tabindex()',
48-
'[attr.aria-haspopup]': '_pattern.hasPopup()',
49-
'[attr.aria-expanded]': '_pattern.expanded()',
47+
'[attr.tabindex]': 'tabindex()',
48+
'[attr.aria-haspopup]': 'hasPopup()',
49+
'[attr.aria-expanded]': 'expanded()',
5050
'[attr.aria-controls]': '_pattern.menu()?.id()',
5151
'(click)': '_pattern.onClick()',
5252
'(keydown)': '_pattern.onKeydown($event)',
@@ -69,6 +69,18 @@ export class MenuTrigger<V> {
6969
/** Whether the menu item has been focused. */
7070
readonly hasBeenFocused = signal(false);
7171

72+
/** Whether the menu is expanded. */
73+
readonly expanded = computed(() => this._pattern.expanded());
74+
75+
/** Whether the menu trigger has a popup. */
76+
readonly hasPopup = computed(() => this._pattern.hasPopup());
77+
78+
/** The role of the menu trigger. */
79+
readonly role = computed(() => this._pattern.role());
80+
81+
/** The tabindex of the menu trigger. */
82+
readonly tabindex = computed(() => this._pattern.tabindex());
83+
7284
/** The menu trigger ui pattern instance. */
7385
_pattern: MenuTriggerPattern<V> = new MenuTriggerPattern({
7486
element: computed(() => this._elementRef.nativeElement),
@@ -183,8 +195,17 @@ export class Menu<V> {
183195
*/
184196
readonly items = () => this._items().map(i => i._pattern);
185197

198+
/** Whether the menu or any of its child elements are currently focused. */
199+
readonly isFocused = computed(() => this._pattern.isFocused());
200+
201+
/** Whether the menu has received focus. */
202+
readonly hasBeenFocused = computed(() => this._pattern.hasBeenFocused());
203+
186204
/** Whether the menu is visible. */
187-
isVisible = computed(() => this._pattern.isVisible());
205+
readonly isVisible = computed(() => this._pattern.isVisible());
206+
207+
/** The role of the menu */
208+
readonly role = computed(() => this._pattern.role());
188209

189210
/** A callback function triggered when a menu item is selected. */
190211
onSelect = output<V>();
@@ -313,6 +334,12 @@ export class MenuBar<V> {
313334
/** The delay in seconds before the typeahead buffer is cleared. */
314335
readonly typeaheadDelay = input<number>(0.5);
315336

337+
/** Whether the menubar or any of its child elements are currently focused. */
338+
readonly isFocused = computed(() => this._pattern.isFocused());
339+
340+
/** Whether the menubar has received focus. */
341+
readonly hasBeenFocused = computed(() => this._pattern.hasBeenFocused());
342+
316343
/** The menu ui pattern instance. */
317344
readonly _pattern: MenuBarPattern<V>;
318345

0 commit comments

Comments
 (0)