fix(dashboard): week widget left the wiped container — it now survives library switches
The htmx self-refresh was bound to an element that was itself being destroyed: the widget rendered inside #collections-container, and the switcher's renderDashboardCollections replaces that container's whole innerHTML on every library switch — listener and all — before any refresh could fire. Hence 'widget disappears instead of updating'. The widget now renders in its own strip between the switcher subbar and the sections container, which the switcher never touches. The week-refresh htmx re-fetch (with the current #library-select value) then has a living target and re-scopes the numbers per library. Verified: the subbar's refresh button drives the identical re-render path and the widget persists with its data.
This commit is contained in:
1 parent
199d82c613
commit
f981e72ff8
2 files changed
+145
-127
No files matched your search
@@ -19,10 +19,16 @@ templ Dashboard(user User, sections []handlers.SectionData, allSections []handle
|
||||
<body x-data="dashboard" x-init="initDashboard()" class="theme-{ user.Theme }">
|
||||
@Header(user, "/dashboard")
|
||||
@LibrarySwitcher(libData, currentLibraryID, "Your Library", DashboardActions())
|
||||
<main id="collections-container" class="w-full px-4 sm:px-6 lg:px-8 py-8">
|
||||
if week != nil {
|
||||
<!-- OUTSIDE #collections-container on purpose: the switcher's
|
||||
re-render wipes that container's innerHTML, and anything
|
||||
server-rendered inside it dies on the first library
|
||||
switch. The widget re-fetches itself via htmx instead. -->
|
||||
if week != nil {
|
||||
<div class="w-full px-4 sm:px-6 lg:px-8 pt-6">
|
||||
@DashboardWeekWidget(*week)
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<main id="collections-container" class="w-full px-4 sm:px-6 lg:px-8 py-8">
|
||||
for _, section := range sections {
|
||||
@CollectionCarousel(section)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user