LearnNewsExamplesConnect
Frontmatter
assigneesneo-opus-vega
createdAtNov 19, 2026, 4:53 AM
updatedAtNov 19, 2026, 11:01 AM
githubUrlhttps://github.com/neomjs/neo/issues/21434
authorneo-opus-vega
commentsCount0
parentIssue21367
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 19, 2026, 11:01 AM

A menu given its tree store as a class or config opens its submenus

neo-opus-vega
neo-opus-vega commented on Nov 19, 2026, 4:53 AM

Owned: a leaf of #21367 until its lock, Sun 22 Nov 18:00 CET.

Context

Defect-note e71871ff, reproduced on dev 5a3cb4de67 at 1024 × 768: in examples/menu/tree, a click on File removes the menu from the stage. Before the click, #neo-menu-list-1 holds File, Edit, View and About; after it, no .neo-menu-list is in the DOM, and the console holds no error.

The Problem

menu.List#beforeSetStore recognises a tree store only as an instance: value instanceof TreeStore (src/menu/List.mjs:334). The example passes the class, store: MainStore. The tree store then becomes the level's own store, and sourceStore stays null. It still looks right: a TreeStore's items are its visible rows, and with every parent collapsed those are the four roots. hasChildren() then falls back to nested items (:612-619), so every parent reads as a leaf. A click on File takes the leaf branch of onKeyDownEnter() (:789-794), and hideOnLeafItemClick unmounts the root.

The Architectural Reality

Design authority: menu.List#beforeSetStore's JSDoc, "the tree store is kept as sourceStore and this level receives its own flat store holding exactly the records it renders" (src/menu/List.mjs:326-327), with @param {Object|Neo.data.Store|Neo.data.TreeStore} value. Its parent list.Base#beforeSetStore takes an instance, a class or a config through ClassSystemUtil.beforeSetInstance(value, Store) (src/list/Base.mjs).

  • #17839's trap holds: submenus share the root's tree store and must never destroy it. They receive it as an instance (:593-597).
  • An instance handed in stays its owner's: menu.List#destroy only unregisters from sourceStore (:466-472).
  • The source is bound once, in onConstructed() (:765-782): a store set later reaches neither the level nor the listeners.

The Fix

  • src/menu/List.mjs
    • beforeSetStore: a class or config is built first, through ClassSystemUtil.beforeSetInstance(value, Store), so a tree store is recognised however it arrives.
    • A tree store this menu built is its own, and destroy() destroys it after the submenus. One handed in as an instance stays its owner's.
    • A store that replaces another after construction retires the old cascade and its listeners, releases an old source the menu built, and fills the root from the new source (afterSetStore).
  • test/playwright/unit/menu/ListTreeStore.spec.mjs: arms for the class and the config form, for ownership, and for a live replacement.

Decision Record impact

none

Acceptance Criteria

  • AC-1: In examples/menu/tree, a click on File keeps the menu and opens File's submenu (New, Open, Save).
  • AC-2: A tree store passed as an instance, a class or a config drives the same levels: hasChildren() reads isLeaf, and a parent opens its submenu.
  • AC-3: A menu destroys a tree store it built from a class or config, never one passed in as an instance, and never from a submenu. A store that replaces the source after construction re-derives the root, retires the open cascade and releases only a source the menu built.

Out of Scope

  • hasChildren()'s nested-items fallback for a plain store: it is the classic API.
  • The example's catalog record and cover (#21142, the renewal under #21367).

Avoided Traps

  • Passing an instance in the example. It hides the engine gap for the next consumer, and the example would then own a store nobody destroys.
  • autoDestroyStore for the source. It governs the level store; reading it for the source would destroy instances other owners share.

Related

Live latest-open + closed sweep: checked latest 20 open + open and closed search (menu TreeStore; menu.List TreeStore; Out of Scope and Avoided Traps read on #17839) at 2026-11-19T03:52:47Z; no equivalent or prior exclusion found. Backlog band: 78 open (red); folds under its owning epic #21367. A2A claim sweep: last 8 messages, no claim on menus. MC sweep: "menu list tree store click on a parent item empties the menu, treated as a leaf", 5 results; #17839's implementation, no decision on store forms. Own-assignment sweep: 11 open, none overlapping.

Retrieval Hint: "menu tree store passed as a class, parent treated as leaf, root unmounts"