From 56dcbeb0cd7551e01fd745457ea3dc323b4e9c1d Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Tue, 24 Oct 2023 23:31:31 +0700 Subject: [PATCH] Fully rework format action (#3877) Signed-off-by: Andrey Sobolev --- .../src/components/list/ListCategories.svelte | 15 +++++++++------ .../src/components/list/ListCategory.svelte | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/view-resources/src/components/list/ListCategories.svelte b/plugins/view-resources/src/components/list/ListCategories.svelte index adff48df30..72c3a59157 100644 --- a/plugins/view-resources/src/components/list/ListCategories.svelte +++ b/plugins/view-resources/src/components/list/ListCategories.svelte @@ -301,8 +301,9 @@ } else { const obj = stateObjs[statePos - 1] if (obj !== undefined) { - if (!noScroll) scrollInto(objState, obj) - dispatch('row-focus', obj) + const focusDoc = listListCategory[objState]?.getLimited().find((it) => it._id === obj._id) ?? obj + if (!noScroll) scrollInto(objState, focusDoc) + dispatch('row-focus', focusDoc) } } return @@ -321,16 +322,18 @@ } else { const obj = stateObjs[statePos + 1] if (obj !== undefined) { - if (!noScroll) scrollInto(objState, obj) - dispatch('row-focus', obj) + const focusDoc = listListCategory[objState]?.getLimited().find((it) => it._id === obj._id) ?? obj + if (!noScroll) scrollInto(objState, focusDoc) + dispatch('row-focus', focusDoc) } } return } } if (offset === 0) { - if (!noScroll) scrollInto(objState, obj) - dispatch('row-focus', obj) + const focusDoc = listListCategory[objState]?.getLimited().find((it) => it._id === obj._id) ?? obj + if (!noScroll) scrollInto(objState, focusDoc) + dispatch('row-focus', focusDoc) } } else { listCategory[objState]?.select(offset, of, dir, noScroll) diff --git a/plugins/view-resources/src/components/list/ListCategory.svelte b/plugins/view-resources/src/components/list/ListCategory.svelte index 3d6e87179f..02524e2bd4 100644 --- a/plugins/view-resources/src/components/list/ListCategory.svelte +++ b/plugins/view-resources/src/components/list/ListCategory.svelte @@ -110,6 +110,10 @@ (res) => { items = res loading = false + const focusDoc = items.find((it) => it._id === $focusStore.focus?._id) + if (focusDoc) { + handleRowFocused(focusDoc) + } }, { ...resultOptions, limit: limit ?? 200 } )