File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ export class MenuBar<V> {
104104 readonly _pattern : MenuBarPattern < V > ;
105105
106106 /** The menu items as a writable signal. */
107- private readonly _itemPatterns = signal < any [ ] > ( [ ] ) ;
107+ private readonly _itemPatterns = computed ( ( ) => this . _items ( ) . map ( i => i . _pattern ) ) ;
108108
109109 /** A callback function triggered when a menu item is selected. */
110110 readonly itemSelected = output < V > ( ) ;
@@ -123,10 +123,6 @@ export class MenuBar<V> {
123123 element : computed ( ( ) => this . _elementRef . nativeElement ) ,
124124 } ) ;
125125
126- afterRenderEffect ( ( ) => {
127- this . _itemPatterns . set ( this . _items ( ) . map ( i => i . _pattern ) ) ;
128- } ) ;
129-
130126 afterRenderEffect ( ( ) => {
131127 this . _pattern . setDefaultStateEffect ( ) ;
132128 } ) ;
Original file line number Diff line number Diff line change @@ -176,11 +176,13 @@ export class Menu<V> {
176176 // Focuses an active menu item when the menu becomes visible. This is needed to
177177 // properly restore focus to the active item when returning to a menu, and to
178178 // focus the first item when navigating into a submenu with hover.
179- afterRenderEffect ( ( ) => {
180- if ( this . _pattern . visible ( ) ) {
181- const activeItem = untracked ( ( ) => this . _pattern . inputs . activeItem ( ) ) ;
182- this . _pattern . listBehavior . goto ( activeItem ! ) ;
183- }
179+ afterRenderEffect ( {
180+ write : ( ) => {
181+ if ( this . visible ( ) ) {
182+ const activeItem = untracked ( ( ) => this . _pattern . inputs . activeItem ( ) ) ;
183+ this . _pattern . listBehavior . goto ( activeItem ! ) ;
184+ }
185+ } ,
184186 } ) ;
185187
186188 afterRenderEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments