Skip to content

Commit 0f85a02

Browse files
committed
feat(ui): add scrollToTop and auto-scroll on tab change in settings modal
1 parent e34a8d5 commit 0f85a02

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

apps/desktop/src/components/ConfigurableScrollableContainer.svelte

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
scrollableContainer.scrollToBottom();
1919
}
2020
}
21+
22+
// Export method to scroll to top
23+
export function scrollToTop() {
24+
if (scrollableContainer?.scrollToTop) {
25+
scrollableContainer.scrollToTop();
26+
}
27+
}
2128
</script>
2229

2330
<ScrollableContainer

apps/desktop/src/components/SettingsModalLayout.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@
2727
2828
let currentSelectedId = $state(selectedId || pages[0]?.id || '');
2929
const currentPage = $derived(pages.find((p) => p.id === currentSelectedId));
30+
let scrollableContainer: ConfigurableScrollableContainer;
3031
3132
function selectPage(pageId: string) {
3233
currentSelectedId = pageId;
3334
onSelectPage(pageId);
3435
}
36+
37+
$effect(() => {
38+
if (currentSelectedId) {
39+
scrollableContainer?.scrollToTop();
40+
}
41+
});
3542
</script>
3643

3744
<div class="modal-settings-wrapper">
@@ -64,7 +71,7 @@
6471
</div>
6572

6673
<section class="page-view" use:focusable={{ vertical: true }}>
67-
<ConfigurableScrollableContainer>
74+
<ConfigurableScrollableContainer bind:this={scrollableContainer}>
6875
<div class="page-view__content">
6976
{@render content({ currentPage })}
7077
</div>

0 commit comments

Comments
 (0)