Skip to content

Commit 4a290ab

Browse files
feat: add focus options in conjunction with shouldFocusDOMNode (#139)
Co-authored-by: Max Cohen <Max.Cohen@mlb.com>
1 parent a708581 commit 4a290ab

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/SpatialNavigation.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ class SpatialNavigationService {
189189
*/
190190
private parentsHavingFocusedChild: string[];
191191

192+
/**
193+
* When shouldFocusDOMNode is true, this prop specifies the focus options that should be passed to the element being focused.
194+
*/
195+
private domNodeFocusOptions: FocusOptions;
196+
192197
private enabled: boolean;
193198

194199
/**
@@ -544,6 +549,7 @@ class SpatialNavigationService {
544549
*/
545550
this.parentsHavingFocusedChild = [];
546551

552+
this.domNodeFocusOptions = {};
547553
this.enabled = false;
548554
this.nativeMode = false;
549555
this.throttle = 0;
@@ -596,10 +602,12 @@ class SpatialNavigationService {
596602
throttleKeypresses = false,
597603
useGetBoundingClientRect = false,
598604
shouldFocusDOMNode = false,
605+
domNodeFocusOptions = {},
599606
shouldUseNativeEvents = false,
600607
rtl = false
601608
} = {}) {
602609
if (!this.enabled) {
610+
this.domNodeFocusOptions = domNodeFocusOptions;
603611
this.enabled = true;
604612
this.nativeMode = nativeMode;
605613
this.throttleKeypresses = throttleKeypresses;
@@ -1385,7 +1393,7 @@ class SpatialNavigationService {
13851393
const newComponent = this.focusableComponents[this.focusKey];
13861394

13871395
if (this.shouldFocusDOMNode && newComponent.node) {
1388-
newComponent.node.focus();
1396+
newComponent.node.focus(this.domNodeFocusOptions);
13891397
}
13901398

13911399
newComponent.onUpdateFocus(true);

0 commit comments

Comments
 (0)