File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ export function getTrapStack() {
2626 *
2727 * When some component manually implements its own focus-trap without using global focus-trap stack,
2828 * it also needs to pause the global stack to avoid conflict.
29+ *
30+ * Note: if global focus-trap stack was modified outside TrapStackController (likely due to user actions),
31+ * trap queue should be correctly handled by focus-trap itself.
32+ * It is no longer safe to unpause cached `pausedStack`, as it can disrupt the current focus trap state.
33+ * We assume that the focus-trap stack is self-regulated and ignore unpause.
2934 */
3035export function createTrapStackController ( ) {
3136 /**
@@ -45,10 +50,13 @@ export function createTrapStackController() {
4550 } ,
4651 /**
4752 * Unpause the paused focus trap stack
53+ * If the actual stack is different from the paused one, ignore unpause.
4854 */
4955 unpause ( ) {
50- for ( const trap of pausedStack ) {
51- trap . unpause ( )
56+ if ( pausedStack . length === getTrapStack ( ) . length ) {
57+ for ( const trap of pausedStack ) {
58+ trap . unpause ( )
59+ }
5260 }
5361 pausedStack = [ ]
5462 } ,
You can’t perform that action at this time.
0 commit comments