Skip to content

Commit

Permalink
fix: ensure Tab deep-linking to redirect to hash with "#"
Browse files Browse the repository at this point in the history
Related to foundation#11527
  • Loading branch information
ncoden committed Oct 9, 2018
1 parent 8d4a13e commit 7bccec6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions js/foundation.tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ class Tabs extends Plugin {
var $oldTab = this.$element.
find(`.${this.options.linkClass}.${this.options.linkActiveClass}`),
$tabLink = $target.find('[role="tab"]'),
hash = $tabLink.attr('data-tabs-target') || $tabLink[0].hash.slice(1),
$targetContent = this.$tabContent.find(`#${hash}`);
target = $tabLink.attr('data-tabs-target'),
anchor = target && target.length ? `#${target}` : $tabLink[0].hash,
$targetContent = this.$tabContent.find(anchor);

//close old tab
this._collapseTab($oldTab);
Expand All @@ -270,9 +271,9 @@ class Tabs extends Plugin {
//either replace or update browser history
if (this.options.deepLink && !historyHandled) {
if (this.options.updateHistory) {
history.pushState({}, '', hash);
history.pushState({}, '', anchor);
} else {
history.replaceState({}, '', hash);
history.replaceState({}, '', anchor);
}
}

Expand Down

0 comments on commit 7bccec6

Please # to comment.