From 1605e3770a5fd92014f2e424885be3a2341aaff2 Mon Sep 17 00:00:00 2001 From: Daniel Ruf Date: Wed, 20 Feb 2019 23:04:46 +0100 Subject: [PATCH] fix: collapse only own elements in accordion and tabs if they contain the target --- js/foundation.accordion.js | 22 +++++++++++----------- js/foundation.tabs.js | 18 +++++++++--------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/js/foundation.accordion.js b/js/foundation.accordion.js index a8aa3b43a..d2e42f916 100644 --- a/js/foundation.accordion.js +++ b/js/foundation.accordion.js @@ -84,18 +84,18 @@ class Accordion extends Plugin { // Whether the anchor element that has been found is part of this element var isOwnAnchor = !!($anchor.length && $link.length); - // If there is an anchor for the hash, open it (if not already active) - if ($anchor && $link && $link.length) { - if (!$link.parent('[data-accordion-item]').hasClass('is-active')) { - this._openSingleTab($anchor); - }; - } - // Otherwise, close everything - else { - this._closeAllTabs(); - } - if (isOwnAnchor) { + // If there is an anchor for the hash, open it (if not already active) + if ($anchor && $link && $link.length) { + if (!$link.parent('[data-accordion-item]').hasClass('is-active')) { + this._openSingleTab($anchor); + }; + } + // Otherwise, close everything + else { + this._closeAllTabs(); + } + // Roll up a little to show the titles if (this.options.deepLinkSmudge) { onLoad($(window), () => { diff --git a/js/foundation.tabs.js b/js/foundation.tabs.js index cf86e5d4e..ffc6a0c4a 100644 --- a/js/foundation.tabs.js +++ b/js/foundation.tabs.js @@ -119,16 +119,16 @@ class Tabs extends Plugin { // Whether the anchor element that has been found is part of this element var isOwnAnchor = !!($anchor.length && $link.length); - // If there is an anchor for the hash, select it - if ($anchor && $anchor.length && $link && $link.length) { - this.selectTab($anchor, true); - } - // Otherwise, collapse everything - else { - this._collapse(); - } - if (isOwnAnchor) { + // If there is an anchor for the hash, select it + if ($anchor && $anchor.length && $link && $link.length) { + this.selectTab($anchor, true); + } + // Otherwise, collapse everything + else { + this._collapse(); + } + // Roll up a little to show the titles if (this.options.deepLinkSmudge) { var offset = this.$element.offset(); -- 2.47.2