Visitar URL original
USWDS - Bug: In-page navigation breaks for headings inside a USWDS alert component · Issue #6295 · uswds/uswds · GitHub
Skip to content

USWDS - Bug: In-page navigation breaks for headings inside a USWDS alert component #6295

Closed

Description

@mgwalker

Describe the bug

The alert component creates a positioned container element (.usa-alert__body) that creates a new offset frame. The in-page navigation component then inserts an anchor inside the alert component. When clicking the link in the in-page navigation, it uses the anchor's offsetTop, which is the vertical distance between the selected element and its nearest offset parent. In this case, it's nearest offset parent is the alert container, not the page body itself.

Steps to reproduce the bug

  1. Browse to https://handbook.tts.gsa.gov/tools/git-signing
  2. Click About the cryptographic algorithm in the in-page nav
  3. Note that the page scrolls to the top rather than to the linked heading

Expected Behavior

The browser should scroll to the selected heading, perhaps using getBoundingClientRect instead of offsetTop since the former computes absolute values (relative to the page, not any other elements in the tree).

Related code

https://github.com/uswds/uswds/blob/main/packages/usa-in-page-navigation/src/index.js#L202

Screenshots

No response

System setup

  • USWDS version: 3.11.0
  • All browsers

Additional context

Possibly related to:

Code of Conduct

Activity

  1. mejiaj commented on Jan 23, 2025

    @mejiaj
    Contributor

    Need to confirm if fixed by #5878.

  2. added
    Package: In-page navigationWork affecting In-page navigation. Apply only when this area helps route or find the issue.
    and removed on Jan 23, 2025
  3. mejiaj commented on Jan 23, 2025

    @mejiaj
    Contributor

    @cathybaptista scheduling for confirmation please ping me or @mahoneycm if you can't get to this on 01/24.

  4. added
    Added during SprintHistorical record of work added during a sprint. Not required for current triage.
    on Jan 23, 2025
  5. moved this from On deck to In progress in USWDS Core Project Dataon Jan 24, 2025
  6. cathybaptista commented on Jan 24, 2025

    @cathybaptista
    Contributor

    @mejiaj , @mahoneycm confirmed that this issue fixed by #5878. I also confirmed the fix in this PR for the alert component.

  7. moved this from In progress to Review in USWDS Core Project Dataon Jan 27, 2025
  8. removed
    Needs: ConfirmationReported behavior needs validation. Remove after recording reproduction or investigation results.
    on Jan 27, 2025
  9. dct2023 commented on Jan 27, 2025

    @dct2023

    Confirmed this is done.

  10. moved this from Review to Done in USWDS Core Project Dataon Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Added during SprintHistorical record of work added during a sprint. Not required for current triage.Package: In-page navigationWork affecting In-page navigation. Apply only when this area helps route or find the issue.

Type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions