From a161e3a520e1abebaf25fee190bdb953c579d876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 27 Jan 2024 22:22:07 +0100 Subject: [PATCH] Load the link again when clicking a already selected treeview node, instead of just unselecting it This fixes the somehow unintuitive behavior described in issue #458 --- assets/controllers/elements/tree_controller.js | 3 ++- yarn.lock | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/assets/controllers/elements/tree_controller.js b/assets/controllers/elements/tree_controller.js index c9d8b213..c6575db8 100644 --- a/assets/controllers/elements/tree_controller.js +++ b/assets/controllers/elements/tree_controller.js @@ -132,7 +132,8 @@ export default class extends Controller { //We only compare the pathname, because the hash and parameters should not matter if(window.location.pathname !== desired.pathname) { - node.setSelected(false); + //The ignore parameter is important here, otherwise the node will not be unselected + node.setSelected(false, {silent: true, ignorePreventUnselect: true}); //Unregister the watcher document.removeEventListener('turbo:visit', unselectNode); diff --git a/yarn.lock b/yarn.lock index 492d820f..d566f440 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1534,9 +1534,9 @@ integrity sha512-Dcu+NaSvHLT7EjrDrkEmH4qET2ZJZ5IcCWmNXxNQTBwlnE5tBZfN6WxZ842n5cHV52DH/AKNirbPBtcEXDLW4g== "@jbtronics/bs-treeview@^1.0.1": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@jbtronics/bs-treeview/-/bs-treeview-1.0.4.tgz#aecd128c295ebd1af904d9a77f17dbf77a772b8f" - integrity sha512-ofhMY+4w0xYHcMPyw53EzWABzrzX2ecm50hhD9Kbb6h1/XsmLzVvHLIG9FYJ3eaIR0nTYF9a5L7mS14Qr/JChQ== + version "1.0.5" + resolved "https://registry.yarnpkg.com/@jbtronics/bs-treeview/-/bs-treeview-1.0.5.tgz#3267138a47624c492e3fa6c94888e5dce78809ab" + integrity sha512-f+IRGnSGa21P7CGmvv5g3cqjC589hDhyc6AHdLj5VXKVqD1EYw5nXdOudgQmTOlqhZa+JGdsfQx8TlFIp313KA== "@jest/schemas@^29.6.3": version "29.6.3"