fix: preserve shopping list scroll position #1

Merged
exler merged 1 commit from fix/shopping-list-scroll-position into main 2026-08-31 19:49:10 +02:00
Collaborator

Summary

  • Fix the shopping list scrolling to the bottom when checking/unchecking or removing an item on some Android/Chrome phones (reproduced on Samsung + Chrome; Pixel + Firefox was unaffected).
  • Blur the toggle, remove, and "Clear checked items" buttons on click, before their HTMX response OOB-swaps the board.

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

  • djlint on the three changed templates
  • Manual QA
## Summary - Fix the shopping list scrolling to the bottom when checking/unchecking or removing an item on some Android/Chrome phones (reproduced on Samsung + Chrome; Pixel + Firefox was unaffected). - Blur the toggle, remove, and "Clear checked items" buttons on click, before their HTMX response OOB-swaps the board. ## 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 - djlint on the three changed templates - Manual QA
exler requested review from exler 2026-08-31 19:25:30 +02:00
exler force-pushed fix/shopping-list-scroll-position from 2b5eb19533 to 2adfea1fe5
All checks were successful
Push Docker Image / push (push) Successful in 4m29s
2026-08-31 19:46:04 +02:00
Compare
exler merged commit 2adfea1fe5 into main 2026-08-31 19:49:10 +02:00
exler deleted branch fix/shopping-list-scroll-position 2026-08-31 19:49:10 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
exler/hearth!1
No description provided.