Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions goldens/aria/private/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ export class MenuPattern<V> {
_clearTimeouts(): void;
close(): void;
closeAll(): void;
_closeTimeout: any;
collapse(): void;
readonly disabled: () => boolean;
readonly dynamicSpaceKey: SignalLike<"" | " ">;
Expand All @@ -451,6 +450,7 @@ export class MenuPattern<V> {
// (undocumented)
readonly inputs: MenuInputs<V>;
readonly isFocused: WritableSignalLike<boolean>;
readonly items: () => MenuItemPattern<V>[];
readonly keydownManager: SignalLike<KeyboardEventManager<KeyboardEvent>>;
last(): void;
readonly listBehavior: List<MenuItemPattern<V>, V | undefined>;
Expand All @@ -461,7 +461,6 @@ export class MenuPattern<V> {
onKeydown(event: KeyboardEvent): void;
onMouseOut(event: MouseEvent): void;
onMouseOver(event: MouseEvent): void;
_openTimeout: any;
prev(): void;
readonly role: () => string;
readonly root: SignalLike<MenuTriggerPattern<V> | MenuBarPattern<V> | MenuPattern<V> | undefined>;
Expand Down
15 changes: 11 additions & 4 deletions src/aria/private/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,14 @@ export class MenuPattern<V> {
/** Whether the menu trigger has been hovered. */
readonly hasBeenHovered = signal(false);

/** Items currently inside the menu. */
readonly items = () => this.inputs.items();

/** Timeout used to open sub-menus on hover. */
_openTimeout: any;
private _openTimeout: ReturnType<typeof setTimeout> | undefined;

/** Timeout used to close sub-menus on hover out. */
_closeTimeout: any;
private _closeTimeout: ReturnType<typeof setTimeout> | undefined;

/** The tab index of the menu. */
readonly tabIndex = () => this.listBehavior.tabIndex();
Expand Down Expand Up @@ -246,7 +249,7 @@ export class MenuPattern<V> {
}

const parent = this.inputs.parent();
const activeItem = this?.inputs.activeItem();
const activeItem = this.inputs.activeItem();

if (parent instanceof MenuItemPattern) {
const grandparent = parent.inputs.parent();
Expand Down Expand Up @@ -689,7 +692,11 @@ export class MenuTriggerPattern<V> {
pendingFocusEffect(): void {
const menu = this.inputs.menu();
const intent = this.pendingFocus();
if (menu && intent) {
const items = menu?.items();

// We check the items so that we don't try calling into
// `first/last` until the items are actually available.
if (menu && intent && items?.length) {
if (intent === 'first') {
menu.first();
} else if (intent === 'last') {
Expand Down
Loading