From 66318c475961b78b0c45cd46d8c0cf5d4a0b683a Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 26 May 2026 02:40:41 +0200 Subject: [PATCH] fix(tree-view): target branches for emerge-expand/collapse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Morfo declaraba target='item' para emerge-expand y emerge-collapse, pero los items son hojas — no se expanden. El stamp del data-event-* debe aterrizar en el branch (data-tree-view-branch), que es el part que realmente revela/oculta contenido. - Morfo: target: v.partRef('item') → v.partRef('branch') en ambos events de emerge. commit-select sigue en item (selección aplica tanto a leaves como a branches). - Pack: selector `onItem(emerge-*)` → `onBranch(emerge-*)`. Las dos cascadas de emerge ahora matchean el elemento correcto en DOM. tree-grid no afectado: su Row es a la vez item y branch (data-has- children + data-expanded en el mismo part), así que target='row' ya estaba correcto. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/uix/morfo/components/tree-view.ts | 12 +++++++++--- src/uix/sema/components/tree-view.ts | 27 ++++++++++++++------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/uix/morfo/components/tree-view.ts b/src/uix/morfo/components/tree-view.ts index ce3a4ec63..ff0941f37 100644 --- a/src/uix/morfo/components/tree-view.ts +++ b/src/uix/morfo/components/tree-view.ts @@ -32,22 +32,28 @@ export const treeViewMorfo = { // sección desplegable)." Tree expand fits exactly. Was // misclassified as `shift.navigate` (which is for context/regime // change, not content revealing). + // + // Target is `branch` (not `item`): items are leaves — they + // don't expand. The data-event-* stamp lands on the branch + // element (`data-tree-view-branch`), which is what the sema + // pack selector targets. name: 'emerge-expand', semantic: { family: 'emerge', verb: 'expand', - target: v.partRef('item'), + target: v.partRef('branch'), sequence: 'post' } }, { // Collapse a node — per book cap. 26: "emerge.collapse — una - // región se contrae." + // región se contrae." Target is `branch` for the same reason + // as emerge-expand above. name: 'emerge-collapse', semantic: { family: 'emerge', verb: 'collapse', - target: v.partRef('item'), + target: v.partRef('branch'), sequence: 'post' } } diff --git a/src/uix/sema/components/tree-view.ts b/src/uix/sema/components/tree-view.ts index b56e5b82b..7dedaf779 100644 --- a/src/uix/sema/components/tree-view.ts +++ b/src/uix/sema/components/tree-view.ts @@ -6,10 +6,12 @@ import type { Sema } from '../sema-map'; /** * TreeView perceptual defaults — SOFT EMERGE + COMMIT. * - * TreeView has three event surfaces, all targeting the `item` part: - * - `commit-select` (commit.select, affirm) — leaf or branch selected - * - `emerge-expand` (emerge.expand) — branch reveals children - * - `emerge-collapse` (emerge.collapse) — branch hides children + * TreeView has three event surfaces: + * - `commit-select` on `item` — leaf or branch selected (affirm intent + * via family deltas). Item part covers both leaves and branches + * from the selection standpoint. + * - `emerge-expand` on `branch` — branch reveals children. + * - `emerge-collapse` on `branch` — branch hides children. * * Strategy (book cap. 22 §10 + cap. 26 emerge open/close discipline): * - EXPAND: `emerge.soft` (gain 0.08) — content reveals, ascending @@ -21,15 +23,14 @@ import type { Sema } from '../sema-map'; * content surfaces elsewhere), and the select chime mustn't * compete with that downstream signal. * - * Note on target: morfo declares all three events targeting `item` - * (leaves). Branches also have role="treeitem" but a different part - * marker (`data-tree-view-branch`). If branches end up emitting at - * runtime without the `data-tree-view-item` marker, this cascade will - * miss them — a known concern noted in the morfo declaration audit. - * The pack follows the morfo declaration verbatim; any mismatch is a - * morfo-level fix outside this pack's scope. + * Target split: expand/collapse target `branch` because items are + * leaves — they don't expand. The DOM marker on a branch is + * `data-tree-view-branch`, distinct from `data-tree-view-item`. The + * selectors below honour that split. */ +const onBranch = (matchers?: Parameters>[2]) => + semaSelector(treeViewMorfo, 'branch', matchers); const onItem = (matchers?: Parameters>[2]) => semaSelector(treeViewMorfo, 'item', matchers); @@ -37,11 +38,11 @@ export const treeViewSema: Sema = { name: 'tree-view', cascade: [ { - selector: onItem({ eventName: 'emerge-expand' }), + selector: onBranch({ eventName: 'emerge-expand' }), sound: soundTuning('emerge.soft') }, { - selector: onItem({ eventName: 'emerge-collapse' }), + selector: onBranch({ eventName: 'emerge-collapse' }), sound: soundTuning('emerge.exit.soft') }, {