From 472cb40dda2c223592804612a424244d37d98778 Mon Sep 17 00:00:00 2001 From: Alexander Platov Date: Tue, 7 Feb 2023 07:53:04 +0300 Subject: [PATCH] Auto expand Accordion (#2595) Signed-off-by: Alexander Platov --- .../src/components/AccordionEditor.svelte | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/attachment-resources/src/components/AccordionEditor.svelte b/plugins/attachment-resources/src/components/AccordionEditor.svelte index d91ffdce61..2a09e98240 100644 --- a/plugins/attachment-resources/src/components/AccordionEditor.svelte +++ b/plugins/attachment-resources/src/components/AccordionEditor.svelte @@ -35,6 +35,8 @@ const attachments: AttachmentStyledBox[] = [] const edits: TextEditor[] = [] let hasAttachments: boolean = false + const expanded: boolean[] = [] + items.forEach(() => expanded.push(false)) const flip = (index: number, ev?: MouseEvent): void => { ev?.stopPropagation() @@ -54,6 +56,14 @@ break } } + + const onScroll = (row: number, ev: Event) => { + const target = ev.target as HTMLDivElement + if (target && !expanded[row] && target.clientHeight < target.scrollHeight) { + expanded[row] = true + flip(row) + } + }
@@ -71,7 +81,7 @@ }} > -
+
onScroll(i, ev)}> {#if item.state === 'closed'}