Skip to content

Commit 4c4a111

Browse files
TMHSDigitalclaude
andcommitted
site: the floating button returns to search, where it focuses
The "Top" button scrolled to the page header and then focused the search box about 1,600px further down, so on desktop a keyboard user was left typing into a field off screen. Since the phone fix, the button is also how small screens get the filters back. It is now "Search": it scrolls to the catalog section and focuses the search box without a second scroll. Checked at 1280x900 (with and without reduced motion), 375x800 and 800x400: the search box ends on screen and focused, and typing filters immediately. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wc67NX9MM964uaVGn4bpZJ
1 parent 6d98a5d commit 4c4a111

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎site/public/app.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,10 +634,13 @@
634634
});
635635

636636
const top = $("#to-top");
637+
// Returns to the catalog's search and filters, which on small screens have
638+
// scrolled away. It used to scroll to the page top and then focus search
639+
// further down, leaving keyboard users typing into a field off screen.
637640
top.addEventListener("click", () => {
638641
const reduce = matchMedia("(prefers-reduced-motion: reduce)").matches;
639-
window.scrollTo({ top: 0, behavior: reduce ? "auto" : "smooth" });
640-
search.focus();
642+
$("#catalog").scrollIntoView({ block: "start", behavior: reduce ? "auto" : "smooth" });
643+
search.focus({ preventScroll: true });
641644
});
642645

643646
window.addEventListener("scroll", onScroll, { passive: true });

‎site/public/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ <h2 id="guides-title">Guides</h2>
170170
</footer>
171171

172172
<button type="button" class="to-top" id="to-top" hidden>
173-
<span aria-hidden="true">↑</span> Top
173+
<span aria-hidden="true">↑</span> Search
174174
</button>
175175

176176
<dialog class="entry-dialog" id="entry-dialog" aria-labelledby="dialog-title">

‎site/public/styles.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ input:focus-visible {
10071007

10081008
/* On a phone the wrapped filter panel is about 530px tall, two thirds of the
10091009
screen, and pinning it left a strip for the entries. Small or short screens
1010-
scroll it away with the page instead; "Top" brings it back. */
1010+
scroll it away with the page instead; the floating Search button brings it back. */
10111011
@media (max-width: 640px), (max-height: 600px) {
10121012
.controls {
10131013
position: static;

0 commit comments

Comments
 (0)