Skip to content

Commit

Permalink
Merge pull request #2511 from boltdesignsystem/hotfix/DS-815-accordio…
Browse files Browse the repository at this point in the history
…n-fix

Hotfix v5.4.1
  • Loading branch information
danielamorse committed Jul 12, 2022
2 parents 9507246 + 165f1d4 commit 8359117
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% set content %}
<bolt-text>
Verify deep linking to an accordion item works when inside a Band. For example: <a href="?selected-accordion-item=item-3" class="e-bolt-text-link">?selected-accordion-item=item-3</a>.
</bolt-text>

{% include '@bolt-components-accordion/accordion.twig' with {
items: [
{
trigger: 'Accordion item 1',
content: 'This is the accordion content.',
id: 'item-1',
},
{
trigger: 'Accordion item 2',
content: 'This is the accordion content.',
id: 'item-2',
},
{
trigger: 'Accordion item 3',
content: 'This is the accordion content.',
id: 'item-3',
}
]
} only %}
{% endset %}

{% include '@bolt-components-band/band.twig' with {
content: content,
theme: 'none',
size: 'large',
} only %}
17 changes: 1 addition & 16 deletions packages/components/bolt-accordion/src/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class BoltAccordion extends withContext(BoltElement) {
}
}

async handleDeepLink() {
handleDeepLink() {
if (!this.deepLinkTarget) return;

const deepLinkTargetIndex = this.accordionItemElements.indexOf(
Expand All @@ -311,21 +311,6 @@ class BoltAccordion extends withContext(BoltElement) {
let shouldScrollIntoView;

if (deepLinkTargetIndex !== -1) {
// This Promise is a workaround for a bug that sometimes happens when you
// put an accordion in a band and use deep linking. When the band first
// renders, it interrupts the initial accordion animation and causes
// Handorgel's 'transitionend' event to not fire. @see DS-253 for more.
const closestBand = this.closest('bolt-band');
if (closestBand) {
await new Promise((resolve, reject) => {
closestBand._wasInitiallyRendered && resolve();
closestBand.addEventListener('ready', e => {
e.target === closestBand && resolve();
});
closestBand.addEventListener('error', reject);
});
}

this.accordion.folds[deepLinkTargetIndex].open();
shouldScrollIntoView = true;
}
Expand Down

0 comments on commit 8359117

Please sign in to comment.