Skip to content

Commit

Permalink
fix: opt to simpler solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Arukuen committed May 22, 2024
1 parent b54b554 commit 968c4ab
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/block/accordion/frontend-accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class StackableAccordion {
const preHeight = el.dataset.preHeight

// Prevent text selection while animating
const content = el.querySelector( '.stk-block-accordion__content' )
content.style.userSelect = 'none'
el.style.userSelect = 'none'

// When inside columns, flex prevents the accordion closing animation, this hack fixes it.
const doWrapHack = !! el.closest( '.stk-block-columns' )
Expand All @@ -55,20 +54,9 @@ class StackableAccordion {
}, ANIM_OPTS )
}

// When the animation is done, remove text selection from double click
// and allow text selection again
// When the animation is done, allow text selection again.
el.anim.onfinish = el.anim.oncancel = () => {
if ( window.getSelection ) {
// eslint-disable-next-line @wordpress/no-global-get-selection
const selection = window.getSelection()
if ( selection.removeAllRanges ) {
selection.removeAllRanges()
}
} else if ( document.selection ) {
// For older IE browsers
document.selection.empty()
}
content.style.userSelect = 'auto'
el.style.userSelect = 'auto'
}

if ( doWrapHack ) {
Expand Down

0 comments on commit 968c4ab

Please sign in to comment.