diff --git a/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue b/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue index 9427be57a..b074ee283 100644 --- a/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue +++ b/app/components/Viewer/ObjectTree/Base/CommonTreeView.vue @@ -128,7 +128,6 @@ function handleNormalClick(item: DisplayItem, index: number | undefined): void { if (index !== undefined) { lastActiveIndex.value = index; } - toggleSelect(item.raw); emit("click:item", item.raw); } diff --git a/app/components/Viewer/ObjectTree/Views/ModelTree.vue b/app/components/Viewer/ObjectTree/Views/ModelTree.vue index 9e51b7433..afbd89260 100644 --- a/app/components/Viewer/ObjectTree/Views/ModelTree.vue +++ b/app/components/Viewer/ObjectTree/Views/ModelTree.vue @@ -242,7 +242,6 @@ function getLeafViewerIds(item: CollectionTreeItem): number[] { :scroll-top="currentView?.scrollTop || 0" class="transparent-treeview virtual-tree-height" @update:selected="(val) => onUpdateSelection(val as string[])" - @click:item="onUpdateSelection([$event.id as string, ...visibleComponents])" @update:scroll-top="treeviewStore.setScrollTop(id, $event)" @hover:enter=" ({ item, immediate }) => diff --git a/tests/unit/components/ObjectTreeClick.nuxt.test.ts b/tests/unit/components/ObjectTreeClick.nuxt.test.ts new file mode 100644 index 000000000..2089d3e00 --- /dev/null +++ b/tests/unit/components/ObjectTreeClick.nuxt.test.ts @@ -0,0 +1,35 @@ +// Third party imports +import { describe, expect, test, vi } from "vitest"; +import { mountSuspended } from "@nuxt/test-utils/runtime"; + +// Local imports +import { setupActivePinia, vuetify } from "@ogw_tests/utils"; +import CommonTreeView from "@ogw_front/components/Viewer/ObjectTree/Base/CommonTreeView.vue"; + +vi.setConfig({ testTimeout: 10_000 }); + +const items = [ + { id: "mesh1", title: "Mesh 1" }, + { id: "mesh2", title: "Mesh 2" }, +]; + +describe("object tree row click", () => { + const pinia = setupActivePinia(); + + test.each([ + { name: "a hidden item", selected: [] }, + { name: "a visible item", selected: ["mesh2"] }, + ])("clicking $name activates it without changing its visibility", async ({ selected }) => { + const wrapper = await mountSuspended(CommonTreeView, { + global: { plugins: [vuetify, pinia] }, + props: { items, selected }, + }); + const rows = wrapper.findAll("[data-testid='treeRowWrapper']"); + expect(rows).toHaveLength(items.length); + + await rows[1]?.trigger("click"); + + expect(wrapper.emitted("update:active")?.at(-1)).toStrictEqual([["mesh2"]]); + expect(wrapper.emitted("update:selected")).toBeUndefined(); + }); +});