Skip to content

Commit

Permalink
fix: removing hide class when no-delay is present
Browse files Browse the repository at this point in the history
  • Loading branch information
sivasadobe committed Dec 2, 2024
1 parent da054ac commit 00feea1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions libs/blocks/section-metadata/sticky-section.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function handleStickyPromobar(section, delay) {
if ((section.querySelector(':is(.promobar, .notification)').classList.contains('no-delay'))
|| (delay && section.classList.contains('popup'))) {
hasScrollControl = true;
section.classList.remove('hide-sticky-section');
}
if (!hasScrollControl && main.children[0] !== section) {
stickySectionEl = createTag('div', { class: 'section show-sticky-section' });
Expand Down
24 changes: 24 additions & 0 deletions test/blocks/section-metadata/mocks/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@
</div>
</div>
</div>
<div class="section sticky-bottom-no-delay">
<div class="aside notification small center promobar no-delay">
<div>
<div data-valign="middle"></div>
</div>
<div>
<div data-valign="middle">
<p>
<picture>
<img loading="lazy" alt="" src="" width="750" height="738">
</picture>
</p>
<p><strong>Body M 18/27 Lorem ipsum dolor sit amet, consectetur adipiscing elit. no-delay</strong></p>
<p><strong><a href="">Call to action</a></strong></p>
</div>
</div>
</div>
<div class="section-metadata">
<div>
<div>style</div>
<div>sticky bottom, dark</div>
</div>
</div>
</div>
<div>
<div class="section-metadata">
<div>
Expand Down
8 changes: 8 additions & 0 deletions test/blocks/section-metadata/section-meta.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ describe('Section Metdata', () => {
expect(sec.classList.contains('hide-sticky-section')).not.to.be.true;
});

it('add promobar behaviour to be visible when no-delay', async () => {
const main = document.querySelector('main');
const sec = document.querySelector('.section.sticky-bottom-no-delay .promobar').closest('.section');
const sm = sec.querySelector('.section-metadata');
await init(sm);
expect(main.lastElementChild.classList.contains('hide-sticky-section')).to.be.false;
});

it('should calculate the top position based on header height', async () => {
const sec = document.querySelector('.section.sticky-top');
const header = document.createElement('header');
Expand Down

0 comments on commit 00feea1

Please sign in to comment.