Skip to content

Commit d40038d

Browse files
committed
refactor(aria/menu): use write in afterRenderEffect when setting focus
1 parent 5ee622f commit d40038d

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/aria/menu/menu.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,13 @@ export class Menu<V> {
170170
// submenus. In those cases, the ui pattern is calling focus() before the ui has a chance to
171171
// update the display property. The result is focus() being called on an element that is not
172172
// focusable. This simply retries focusing the element after render.
173-
afterRenderEffect(() => {
174-
if (this._pattern.visible()) {
175-
const activeItem = untracked(() => this._pattern.inputs.activeItem());
176-
this._pattern.listBehavior.goto(activeItem!);
177-
}
173+
afterRenderEffect({
174+
write: () => {
175+
if (this.visible()) {
176+
const activeItem = untracked(() => this._pattern.inputs.activeItem());
177+
this._pattern.listBehavior.goto(activeItem!);
178+
}
179+
},
178180
});
179181

180182
afterRenderEffect(() => {

0 commit comments

Comments
 (0)