diff --git a/app/gui/src/project-view/components/ComponentBrowser/ComponentList.vue b/app/gui/src/project-view/components/ComponentBrowser/ComponentList.vue index 54283513bc50..5750386b108b 100644 --- a/app/gui/src/project-view/components/ComponentBrowser/ComponentList.vue +++ b/app/gui/src/project-view/components/ComponentBrowser/ComponentList.vue @@ -3,7 +3,7 @@ import { makeComponentList, type Component } from '@/components/ComponentBrowser import ComponentEntry from '@/components/ComponentBrowser/ComponentEntry.vue' import type { Filtering } from '@/components/ComponentBrowser/filtering' import SvgIcon from '@/components/SvgIcon.vue' -import LazyList from '@/components/VirtualizedList.vue' +import VirtualizedList from '@/components/VirtualizedList.vue' import { groupColorStyle } from '@/composables/nodeColors' import { useSuggestionDbStore } from '@/stores/suggestionDatabase' import { tryGetIndex } from '@/util/data/array' @@ -23,8 +23,8 @@ const emit = defineEmits<{ }>() const root = ref() -const groupsPanel = ref>() -const componentsPanel = ref>() +const groupsPanel = ref>() +const componentsPanel = ref>() const panels = { groupsPanel, componentsPanel } export type ComponentListPanel = keyof typeof panels @@ -35,15 +35,14 @@ const focusedPanel = ref('componentsPanel') const displayedSelectedComponentIndex = computed({ get: () => (focusedPanel.value === 'groupsPanel' ? null : selectedComponentIndex.value), set: (index) => { - focusedPanel.value = 'componentsPanel' selectedComponentIndex.value = index + if (index != null) { + focusedPanel.value = 'componentsPanel' + } }, }) -watch(toRef(props, 'filtering'), () => { - selectedComponentIndex.value = 0 - focusedPanel.value = 'componentsPanel' -}) +watch(toRef(props, 'filtering'), () => (displayedSelectedComponentIndex.value = 0)) watch(selectedGroupIndex, () => (selectedComponentIndex.value = 0)) const suggestionDbStore = useSuggestionDbStore() @@ -88,6 +87,8 @@ defineExpose({ break case 'groupsPanel': focusedPanel.value = 'componentsPanel' + // VirtualizedList component may have set selection to null on item list update. + selectedComponentIndex.value = 0 break } }, @@ -98,7 +99,7 @@ defineExpose({