From 8807c00d673152762237348aeedd54e9d2aac934 Mon Sep 17 00:00:00 2001 From: "darkhan.nausharipov" Date: Sat, 5 Nov 2022 14:20:40 +0300 Subject: [PATCH] fixed _getNodeAncestors (#23593) --- .../lib/pages/tour/controllers/content_tree.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/learning/tour-of-beam/frontend/lib/pages/tour/controllers/content_tree.dart b/learning/tour-of-beam/frontend/lib/pages/tour/controllers/content_tree.dart index 77d355f13fad..aba409bebc10 100644 --- a/learning/tour-of-beam/frontend/lib/pages/tour/controllers/content_tree.dart +++ b/learning/tour-of-beam/frontend/lib/pages/tour/controllers/content_tree.dart @@ -73,13 +73,14 @@ class ContentTreeController extends ChangeNotifier { notifyListeners(); } - List _getNodeAncestors(NodeModel node, List ancestors) { + List _getNodeAncestors(NodeModel node, List ancestorIds) { if (node.parent != null) { - ancestors.add(node.parent!.id); - return _getNodeAncestors(node.parent!, ancestors); - } else { - return ancestors.reversed.toList(); + return _getNodeAncestors( + node.parent!, + [...ancestorIds, node.parent!.id], + ); } + return ancestorIds.reversed.toList(); } void _onContentTreeCacheChange() {