LearnNewsExamplesServices
Frontmatter
id9447
titleTreeGrid: Fix 7-click expand/collapse bug and redundant change events
stateClosed
labels
bugaitesting
assigneestobiu
createdAtMar 12, 2026, 11:35 AM
updatedAtMar 12, 2026, 11:37 AM
githubUrlhttps://github.com/neomjs/neo/issues/9447
authortobiu
commentsCount1
parentIssue9404
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMar 12, 2026, 11:37 AM

TreeGrid: Fix 7-click expand/collapse bug and redundant change events

Closed v12.1.0 bugaitesting
tobiu
tobiu commented on Mar 12, 2026, 11:35 AM

Problem

Users reported a bug in the TreeGrid where clicking an expand/collapse icon required 7 clicks before the icon visually updated to reflect the new state, even though rows were added/removed correctly on the first click.

Analysis

The TreeStore.mjs expand and collapse methods were manually firing me.onRecordChange immediately after mutating a node property (e.g., node.collapsed = false). However, since node is guaranteed to be a fully hydrated Record instance (via me.get()), the property mutation itself already triggers the notifyChange setter in RecordFactory, which increments record.version and fires onRecordChange natively.

The duplicate, manual onRecordChange call fired a second event without incrementing the record.version. This caused a race condition in grid.Body and Component.mjs#cellRenderer, where the VDOM update short-circuited because component.lastRecordVersion === record.version. The 7 clicks forced a row recycle, bypassing the short-circuit and finally updating the DOM.

Solution

  1. Removed all redundant manual me.onRecordChange calls in collapse() and expand().
  2. Changed single-property updates to direct assignment (node.collapsed = true), relying on the RecordFactory setter.
  3. Changed multi-property async updates to use batched assignment (node.set({ isLoading: false, collapsed: false })) to fire a single, clean mutate event.
  4. Added an E2E test (GridTree.spec.mjs) to verify the correct node expand/collapse behavior on the first click.
tobiu added the bug label on Mar 12, 2026, 11:35 AM
tobiu added the ai label on Mar 12, 2026, 11:35 AM
tobiu added the testing label on Mar 12, 2026, 11:35 AM
tobiu referenced in commit 4b129db - "bug(TreeGrid): Fix 7-click expand/collapse race condition and redundant events (#9447)" on Mar 12, 2026, 11:36 AM
tobiu assigned to @tobiu on Mar 12, 2026, 11:36 AM
tobiu added parent issue #9404 on Mar 12, 2026, 11:37 AM
tobiu
tobiu Mar 12, 2026, 11:37 AM

Fixed by removing redundant manual onRecordChange calls in TreeStore.mjs and batching multiple property assignments with node.set({...}) to fire a single clean mutate event. E2E test added to verify toggle behavior.

tobiu closed this issue on Mar 12, 2026, 11:37 AM