fix: preserve shopping list scroll position #1
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/shopping-list-scroll-position"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Root cause
Checking an item re-renders the whole shopping board through an out-of-band HTMX swap. On Chrome, when the currently-focused element is removed by that swap and other focusable controls remain on the page — every row's hidden edit form has a
<select name="category">— the browser's focus-fixup logic hunts for a new place to focus/scroll and lands at the bottom of the page. Firefox doesn't do this, which is why it only reproduced on Chrome. This matches a known Chromium bug reported upstream against htmx: https://github.com/bigskysoftware/htmx/issues/3340.Fix
Blur the button in its
onclick, before the request fires, so there's no focused element left for Chrome to re-anchor to when the swap lands. No JS, no stable IDs, no scroll-anchor bookkeeping needed.Verification
2b5eb19533to2adfea1fe5