@@ -154,7 +154,7 @@ export class FocusManager {
154
154
155
155
this . unregisterElement ( element ) ;
156
156
157
- const parentNode = options . isolate ? undefined : this . findParentNode ( element ) ;
157
+ const parentNode = this . findParentNode ( element ) ;
158
158
159
159
const newNode : FocusableNode = {
160
160
element,
@@ -166,14 +166,14 @@ export class FocusManager {
166
166
this . nodeMap . set ( element , newNode ) ;
167
167
this . establishParentChildRelationships ( element , newNode , parentNode ) ;
168
168
this . resolvePendingRelationships ( ) ;
169
- this . handlePendingRegistration ( element , parentNode , options ) ;
169
+ this . handlePendingRegistration ( element , parentNode ) ;
170
170
171
171
if ( this . fModeManager . active ) {
172
172
this . fModeManager . addElement ( element , newNode ) ;
173
173
}
174
174
175
175
if ( options . activate ) {
176
- this . setActiveNode ( newNode ) ;
176
+ this . setActiveNode ( this . findNavigableDescendant ( newNode ) ) ;
177
177
}
178
178
}
179
179
@@ -254,7 +254,7 @@ export class FocusManager {
254
254
( forward && currentIndex === navigableSiblings . length - 1 ) ||
255
255
( ! forward && currentIndex === 0 ) ;
256
256
257
- if ( isAtBoundary ) {
257
+ if ( isAtBoundary && ! parentNode . options . trap ) {
258
258
// Traverse parents while vertical: true
259
259
const linkedTarget = this . findNextInColumnNode ( currentNode , forward ) ;
260
260
if ( ! linkedTarget ) return false ;
@@ -266,7 +266,7 @@ export class FocusManager {
266
266
267
267
focusNextVertical ( forward : boolean ) : boolean {
268
268
if ( ! this . currentNode ?. element ) return false ;
269
- const nextChild = this . findInNextColumn ( this . currentNode . element , forward ) ;
269
+ const nextChild = this . findInNextColumn ( this . currentNode , forward ) ;
270
270
if ( nextChild ) {
271
271
return this . setActiveNode ( nextChild ) ;
272
272
}
@@ -326,6 +326,9 @@ export class FocusManager {
326
326
if ( navigableChild ) {
327
327
return navigableChild ;
328
328
}
329
+ if ( node . options . trap ) {
330
+ return ;
331
+ }
329
332
}
330
333
pointer = pointer . parentElement ;
331
334
}
@@ -521,7 +524,7 @@ export class FocusManager {
521
524
case 'right' :
522
525
if ( trap ) return true ;
523
526
if ( ! this . focusNextVertical ( true ) ) {
524
- this . focusAnyNode ( ) ;
527
+ // this.focusAnyNode();
525
528
}
526
529
return true ;
527
530
@@ -620,8 +623,7 @@ export class FocusManager {
620
623
}
621
624
622
625
// Finds focusable in adjacent column for horizontal navigation
623
- findInNextColumn ( element : HTMLElement , forward : boolean ) : FocusableNode | undefined {
624
- const node = this . getNode ( element ) ;
626
+ findInNextColumn ( node : FocusableNode , forward : boolean ) : FocusableNode | undefined {
625
627
if ( ! node ) return undefined ;
626
628
627
629
let searchNode : FocusableNode | undefined = node . parent ;
@@ -631,7 +633,7 @@ export class FocusManager {
631
633
if ( ! ancestorNode ) return ;
632
634
633
635
// Find the current branch from the non-list parent's perspective
634
- const ancestorChild = this . findChildNodeByDescendent ( ancestorNode , element ) ;
636
+ const ancestorChild = this . findChildNodeByDescendent ( ancestorNode , node ) ;
635
637
if ( ! ancestorChild ) return ;
636
638
637
639
// Find non-button siblings of the current branch for navigation
@@ -663,20 +665,22 @@ export class FocusManager {
663
665
if ( ! current . options . vertical ) {
664
666
return current ;
665
667
}
668
+ if ( current . options . trap ) {
669
+ return ;
670
+ }
666
671
current = current . parent ;
667
672
}
668
- return undefined ;
669
673
}
670
674
671
675
// Finds which child branch contains the given element
672
676
private findChildNodeByDescendent (
673
677
ancestor : FocusableNode ,
674
- element : HTMLElement
678
+ node : FocusableNode
675
679
) : FocusableNode | undefined {
676
680
// Check each child (including buttons) to see which one contains our current element
677
681
// We need to check all children here because we're looking for containment, not navigation
678
682
for ( const child of ancestor . children ) {
679
- if ( this . isNodeDescendantOf ( child , element ) ) {
683
+ if ( this . isNodeDescendantOf ( child , node . element ) ) {
680
684
return child ;
681
685
}
682
686
}
@@ -773,12 +777,8 @@ export class FocusManager {
773
777
} ) ;
774
778
}
775
779
776
- private handlePendingRegistration (
777
- element : HTMLElement ,
778
- parentNode : FocusableNode | undefined ,
779
- options : FocusableOptions
780
- ) {
781
- if ( ! parentNode && ! options . isolate ) {
780
+ private handlePendingRegistration ( element : HTMLElement , parentNode : FocusableNode | undefined ) {
781
+ if ( ! parentNode ) {
782
782
this . pendingRelationships . push ( element ) ;
783
783
}
784
784
}
@@ -1044,7 +1044,6 @@ export class FocusManager {
1044
1044
if ( node . options . disabled ) flags . push ( 'disabled' ) ;
1045
1045
if ( node . options . trap ) flags . push ( 'trap' ) ;
1046
1046
if ( node . options . vertical ) flags . push ( 'vertical' ) ;
1047
- if ( node . options . isolate ) flags . push ( 'isolate' ) ;
1048
1047
if ( this . isContainerElement ( node ) ) flags . push ( 'container' ) ;
1049
1048
const flagsStr = flags . length > 0 ? ` [${ flags . join ( ', ' ) } ]` : '' ;
1050
1049
0 commit comments