From 02cd011a3a40c4f2198476c4eb43c6f2afc140a9 Mon Sep 17 00:00:00 2001 From: Noah Date: Thu, 14 May 2026 17:32:35 +0200 Subject: [PATCH] automatically expand the current children node --- lib/src/model/analysis/analysis_controller.dart | 12 +++++++++++- lib/src/model/study/study_controller.dart | 14 +++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/src/model/analysis/analysis_controller.dart b/lib/src/model/analysis/analysis_controller.dart index 0b7fd869d2..811ffc7c42 100644 --- a/lib/src/model/analysis/analysis_controller.dart +++ b/lib/src/model/analysis/analysis_controller.dart @@ -687,6 +687,16 @@ class AnalysisController extends AsyncNotifier final pathChange = curState.currentPath != path; final (currentNode, opening) = _nodeOpeningAt(_root, path); + bool pathWasExpanded = false; + if (pathChange) { + for (final child in currentNode.children) { + if (child.isCollapsed) { + child.isCollapsed = false; + pathWasExpanded = true; + } + } + } + // always show variation if the user plays a move if (shouldForceShowVariation && currentNode is Branch && currentNode.isCollapsed) { _root.updateAt(path, (node) { @@ -697,7 +707,7 @@ class AnalysisController extends AsyncNotifier // root view is only used to display move list, so we need to // recompute the root view only when the nodelist length changes // or a variation is hidden/shown - final rootView = shouldForceShowVariation || shouldRecomputeRootView + final rootView = shouldForceShowVariation || shouldRecomputeRootView || pathWasExpanded ? _root.view : curState.root; diff --git a/lib/src/model/study/study_controller.dart b/lib/src/model/study/study_controller.dart index 98918f1cc8..7a4381545f 100644 --- a/lib/src/model/study/study_controller.dart +++ b/lib/src/model/study/study_controller.dart @@ -437,6 +437,16 @@ class StudyController extends AsyncNotifier final pathChange = state.currentPath != path; final currentNode = _root.nodeAt(path); + bool pathWasExpanded = false; + if (pathChange) { + for (final child in currentNode.children) { + if (child.isCollapsed) { + child.isCollapsed = false; + pathWasExpanded = true; + } + } + } + // always show variation if the user plays a move if (shouldForceShowVariation && currentNode is Branch && currentNode.isCollapsed) { _root.updateAt(path, (node) { @@ -447,7 +457,9 @@ class StudyController extends AsyncNotifier // root view is only used to display move list, so we need to // recompute the root view only when the nodelist length changes // or a variation is hidden/shown - final rootView = shouldForceShowVariation || shouldRecomputeRootView ? _root.view : state.root; + final rootView = shouldForceShowVariation || shouldRecomputeRootView || pathWasExpanded + ? _root.view + : state.root; final isForward = path.size > state.currentPath.size; if (currentNode is Branch) {