File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -119,13 +119,15 @@ export class Menu<V> {
119119 readonly _pattern : MenuPattern < V > ;
120120
121121 /**
122- * The menu items as a writable signal.
123- *
124- * TODO(wagnermaciel): This would normally be a computed, but using a computed causes a bug where
125- * sometimes the items array is empty. The bug can be reproduced by switching this to use a
126- * computed and then quickly opening and closing menus in the dev app.
122+ * The menu item patterns for the menu items that are direct children of this menu, passed
123+ * to the menu pattern.
127124 */
128- private readonly _itemPatterns = ( ) => this . _items ( ) . map ( i => i . _pattern ) ;
125+ private readonly _itemPatterns = computed ( ( ) => {
126+ // Needed to properly trigger recompute without contentChildren returning partial list.
127+ this . _pattern . visible ( ) ;
128+
129+ return this . _items ( ) . map ( i => i . _pattern ) ;
130+ } ) ;
129131
130132 /** Whether the menu is visible. */
131133 readonly visible = computed ( ( ) => this . _pattern . visible ( ) ) ;
You can’t perform that action at this time.
0 commit comments