@@ -33,6 +33,8 @@ class StackableAccordion {
33
33
// Prevent text selection while animating
34
34
el . style . userSelect = 'none'
35
35
36
+ clearTimeout ( el . textSelectTimeout )
37
+
36
38
// When inside columns, flex prevents the accordion closing animation, this hack fixes it.
37
39
const doWrapHack = ! ! el . closest ( '.stk-block-columns' )
38
40
let wrapper = null
@@ -54,14 +56,18 @@ class StackableAccordion {
54
56
} , ANIM_OPTS )
55
57
}
56
58
57
- // When the animation is done, allow text selection again.
59
+ // When the animation is done, remove wrapper and allow text selection again.
58
60
el . anim . onfinish = el . anim . oncancel = ( ) => {
61
+ if ( doWrapHack ) {
62
+ removeWrapperHack ( el , wrapper )
63
+ }
59
64
el . style . userSelect = 'auto'
60
65
}
61
66
62
- if ( doWrapHack ) {
63
- removeWrapperHack ( el , wrapper )
64
- }
67
+ // Fallback to make sure accordion text is selectable just incase the onfinish or oncancel doesn't fire.
68
+ el . textSelectTimeout = setTimeout ( ( ) => {
69
+ el . style . userSelect = 'auto'
70
+ } , 700 )
65
71
}
66
72
} )
67
73
} )
@@ -197,11 +203,9 @@ class StackableAccordion {
197
203
}
198
204
199
205
const removeWrapperHack = ( el , wrapper ) => {
200
- el . anim . onfinish = el . anim . oncancel = ( ) => {
201
- // Unwrap el from the div
202
- wrapper . parentNode ?. insertBefore ( el , wrapper )
203
- wrapper ?. remove ( )
204
- }
206
+ // Unwrap el from the div
207
+ wrapper . parentNode ?. insertBefore ( el , wrapper )
208
+ wrapper ?. remove ( )
205
209
}
206
210
}
207
211
}
0 commit comments