Skip to content

Commit

Permalink
Update fallback selector
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoffbeck committed Mar 15, 2024
1 parent d02da66 commit fd29e07
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions assets/media-gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ if (!customElements.get('media-gallery')) {
}

setActiveMedia(mediaId) {
const activeMedia = this.elements.viewer.querySelector(`[data-media-id="${mediaId}"],[data-media-id]`);
const activeMedia =
this.elements.viewer.querySelector(`[data-media-id="${mediaId}"]`) ||
this.elements.viewer.querySelector('[data-media-id]');
if (!activeMedia) {
return;
}
this.elements.viewer.querySelectorAll('[data-media-id]').forEach((element) => {
element.classList.remove('is-active');
});
activeMedia.classList.add('is-active');
activeMedia?.classList?.add('is-active');

this.preventStickyHeader();
window.setTimeout(() => {
Expand Down

0 comments on commit fd29e07

Please sign in to comment.