Skip to content

SkipLink double jumps to first heading then #maincontent if disableDefaultBehaviour is not set #166

@waringr

Description

@waringr

Currently if the SkipLink is included without any additional attributes, and there is an element on the page with an id of maincontent, then clicking the skip to content link causes a double jump, first to the heading, then to #maincontent.

A suggested fix would be to always call e.preventDefault, then jump to either the first heading or #maincontent based on the setting of disableDefaultBehaviour and the existence of the id, e.g.

e.preventDefault()
if(!disableDefaultBehaviour && document.getElementById('maincontent')) {
  this.focusElement(document.getElementById('maincontent'))
} else {
  this.focusElement(/* first heading*/)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions