diff --git a/plugins/tracker-resources/src/components/FilterMenuSection.svelte b/plugins/tracker-resources/src/components/FilterMenuSection.svelte index be449f1532..623ad0081b 100644 --- a/plugins/tracker-resources/src/components/FilterMenuSection.svelte +++ b/plugins/tracker-resources/src/components/FilterMenuSection.svelte @@ -18,7 +18,7 @@ import { FilterSectionElement } from '../utils' export let actions: FilterSectionElement[] = [] - export let onBack: () => void + export let onBack: (() => void) | undefined = undefined const dispatch = createEventDispatcher() const actionElements: HTMLButtonElement[] = [] @@ -28,7 +28,7 @@ const getSelectedElementsMap = (actions: FilterSectionElement[]) => { const result: { [k: number]: boolean } = {} - for (let i = 1; i < actions.length; ++i) { + for (let i = onBack ? 1 : 0; i < actions.length; ++i) { result[i] = !!actions[i].isSelected } @@ -46,7 +46,8 @@ if (event.key === 'ArrowLeft') { dispatch('close') - onBack() + + onBack?.() } } @@ -74,25 +75,27 @@ event.currentTarget.focus() }} on:click={(event) => { - if (i === 0) { + if (i === 0 && onBack) { dispatch('close') } action.onSelect(event) - if (i !== 0) { + if (i !== 0 || !onBack) { selectedElementsMap[i] = !selectedElementsMap[i] } }} >