Auto expand Accordion (#2595)

Signed-off-by: Alexander Platov <sas_lord@mail.ru>
This commit is contained in:
Alexander Platov 2023-02-07 07:53:04 +03:00 committed by GitHub
parent 0bee06e8a7
commit 472cb40dda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}
}
</script>
<div class="antiAccordion">
@ -71,7 +81,7 @@
}}
>
<span class="label"><Label label={item.label} /></span>
<div class="value">
<div class="value" on:scroll={(ev) => onScroll(i, ev)}>
{#if item.state === 'closed'}
<TextEditor
bind:content={item.content}