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 @@ -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 ( ( ) => {
You can’t perform that action at this time.
0 commit comments