Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not corrupt location.href when changing deep-linked tabs #12464

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

ameotoko
Copy link
Contributor

@ameotoko ameotoko commented Aug 2, 2022

Description

If HTML page has <base> tag, deep-linked tabs currently rewrite href incorrectly – the pathname is lost.

How to reproduce

It is not possible to set up Codepen demo, because it does not allow history changes (or rather, does not show it in the address bar). However, you can easily reproduce it on a live site.

  1. Visit https://get.foundation/sites/docs/tabs.html#deep-linking. Watch address bar while switching tabs. https://get.foundation/sites/docs/tabs.html#panel1d changes to https://get.foundation/sites/docs/tabs.html#panel2d etc.
  2. Open developer tools and add <base href="https://get.foundation"> to the <head>.
  3. Switch deep-linked tabs again and watch the address bar. https://get.foundation/sites/docs/tabs.html#panel1d now changes to https://get.foundation/#panel2d which is incorrect.

This PR fixes it by explicitly using current path and query string to construct new URL. This makes deep-linked tabs handle history consistently with OR without base tag defined.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

@sonarcloud
Copy link

sonarcloud bot commented Aug 2, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

ameotoko added a commit to ameotoko/contao-skeleton that referenced this pull request Aug 5, 2022
Copy link

sonarcloud bot commented Dec 1, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@joeworkman joeworkman merged commit 29b7a32 into foundation:develop Sep 27, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants