Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When visiting a hash link (
#id
), WET's focus plugin checks whether the destination is situated within a closeddetails
element or tab panel. If so, the plugin automatically expands the destination'sdetails
element or tab panel. The plugin subsequently focuses onto the destination.However, that sometimes causes inconsistent scrolling behaviour. Scrolling will work differently depending on if the link's destination is in the same page or on a separate page.
If a user visits a same-page hash link whose destination is in a closed details element/tab panel, everything works as expected. The plugin will expand the parent and the browser will jump to the destination. The destination will appear at the top of the browser viewport.
If a user visits a hash link whose destination is on a separate page, the plugin will run... but won't jump to the destination. Instead of jumping, the browser will scroll to show the destination at the bottom (Gecko/Trident) or the middle (Blink/Webkit) of the viewport. This is due to the focus plugin causing browsers to incorrectly use their natural focus scrolling behaviour in this context.
This commit corrects that behaviour by adding a flag to always navigate to hashes that are being focused on. As a result, browsers can use their natural link jumping behaviour. It also doesn't add anything to the browser's navigation history (since the hash was already in the page's URL beforehand).