UI: ScrollToTop may miss same-page anchor clicks on nested children #198
Labels
No Label
P0
P1
P2
P3
accessibility
backend
bug
content
data-integrity
enhancement
frontend
infra
integration
owner
owner-input
performance
phase-7
phase-8
release-blocker
security
seo
ui
ux
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: null/Queue-North-Website#198
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
Severity: Minor
Description: Same-page anchor navigation (
#contact-form) is intercepted via click handler, but only catches direct anchor clicks. Clicks on nested children (icons, spans inside links) won't trigger it.File:
src/components/ScrollToTop.jsxFix direction: Use event delegation on nearest container or rely on React Router scroll restoration.
Not a defect — the code already does exactly what the fix direction asks for.
The claim is that the handler 'only catches direct anchor clicks. Clicks on nested children (icons, spans inside links) won't trigger it.'
src/components/ScrollToTop.jsx:23:Element.closest()walks up the DOM from the clicked element to the nearest matching ancestor. A click on an icon or a span inside a link has that<a>as an ancestor, soclosest('a')finds it and the handler runs. Nested children already work.The fix direction says 'use event delegation on nearest container'. Line 33 attaches the listener to
document— that is event delegation, on the broadest container available, which is also why it keeps working for links added after mount.This matters in practice for the hero CTAs, which are exactly the nested case:
<Link to="/contact#contact-form">Schedule Consultation <ArrowRight/></Link>. Clicking the arrow icon resolves to the link throughclosestand scrolls correctly.Closing as no change required.
Verify: read
src/components/ScrollToTop.jsxlines 21-35 — the listener is ondocumentand the target is resolved withe.target.closest('a'), which is the delegation the issue asks to be added.