Skip to content

Links to anchors in web pages are broken if the link points to a parent element #17669

@matuzo

Description

@matuzo

When you link to a fragment in a page (element with a specific id) and that element is the parent of the link, NVDA doesn't jump to the link target but stays on the link and does nothing.

Steps to reproduce:

Actual behavior:

Take the following HTML code or use this demo. Navigate using the arrow keys and press Enter on the "Back to top in main" link. Nothing happens.

<main id="content">
  
  <h1>Top of the page</h1>
    
  <a href="#content">
    Back to top in main
  </a>
</main>

<footer>
  <a href="#content">
    Back to top in footer
  </a>
</footer>

Speech viewer output:
visited link Back to top in main

After pressing Enter on the link:
[ No output ]

If the link is not a child of the target, it works. Navigate using the arrow keys and press Enter on the "Back to top in footer" link. NVDA now announces the target element.

Speech viewer output:
visited link Back to top in footer

After pressing Enter on the link:
main landmark heading level 1 Top of the page link Back to top in main

If you use the Tab key instead of the arrow key both links behave the same and bring you to the target and announce it.

Expected behavior:

It shouldn't matter if the target of the link is a parent or sibling or if you use the Tab key or the arrow keys. Pressing Enter should always bring you to the target, if it exists. At least, that's how it works with VoiceOver and JAWS.

System configuration

NVDA version: 2024.4.2

Windows version: Windows 11 Home

Name and version of other software in use when reproducing the issue: Latest Firefox and Chrome

Other questions

Does the issue still occur after restarting your computer?

Yes

Have you tried any other versions of NVDA? If so, please report their behaviors.

Older versions, same behavior.

If NVDA add-ons are disabled, is your problem still occurring?

No add-ons installed.

Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/chromeapp/firefoxfeature/browse-modep3https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#prioritytriagedHas been triaged, issue is waiting for implementation.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions