Skip to content

Commit

Permalink
Fix scroll to added items
Browse files Browse the repository at this point in the history
  • Loading branch information
scosman committed Oct 8, 2024
1 parent d07ad24 commit 914c290
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/web_ui/src/lib/utils/form_list.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,15 @@
// Trigger reactivity
content = content
if (focus) {
// scroll the add button back into view, which is just past the new item
const list = document.getElementById(id + "_add_button")
if (list) {
// Async to allow rendering first
setTimeout(() => {
// Scroll into view. Async to allow rendering first
setTimeout(() => {
const list = document.getElementById(
"list_item_" + (content.length - 1) + "_" + id,
)
if (list) {
list.scrollIntoView()
}, 1)
}
}
}, 1)
}
}
Expand All @@ -72,7 +73,7 @@
{#if content.length > 0}
<div class="flex flex-col gap-8" {id}>
{#each content as item, item_index}
<div>
<div id={"list_item_" + item_index + "_" + id}>
<div class="flex flex-row gap-3 font-medium text-sm pb-2">
<div class="grow">
{content_label} #{item_index + 1}
Expand Down

0 comments on commit 914c290

Please sign in to comment.