Skip to content

Commit 0e7440b

Browse files
committed
Revert "Skip back button when auto-focusing first interactive element in dialog"
This reverts commit 9123104.
1 parent 3190100 commit 0e7440b

2 files changed

Lines changed: 1 addition & 23 deletions

File tree

src/hooks/useDialogContainerFocus/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import FOCUSABLE_SELECTOR from '@libs/focusableSelector';
55
import hasFocusableAttributes from '@libs/focusGuards';
66
import getHadTabNavigation from '@libs/hadTabNavigation';
77
import {Priorities, tryClaim} from '@libs/ScreenFocusArbiter';
8-
import CONST from '@src/CONST';
98
import type UseDialogContainerFocus from './types';
109

1110
function focusFirstInteractiveElement(container: HTMLElement | null): boolean {
1211
if (!getHadTabNavigation() || !container || (document.activeElement && document.activeElement !== document.body)) {
1312
return false;
1413
}
1514
const targets = container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR);
16-
const target = Array.from(targets).find((el) => hasFocusableAttributes(el) && el.id !== CONST.BACK_BUTTON_NATIVE_ID);
15+
const target = Array.from(targets).find(hasFocusableAttributes);
1716
if (!target) {
1817
return false;
1918
}

tests/unit/focusFirstInteractiveElementTest.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -303,27 +303,6 @@ describe('focusFirstInteractiveElement', () => {
303303
expect(buttonSpy).toHaveBeenCalled();
304304
});
305305

306-
it('should skip the back button (BACK_BUTTON_NATIVE_ID) and focus the next element', () => {
307-
const backButton = document.createElement('button');
308-
backButton.id = 'backButton';
309-
const nextButton = document.createElement('button');
310-
const container = createContainer(backButton, nextButton);
311-
const backSpy = jest.spyOn(backButton, 'focus');
312-
const nextSpy = jest.spyOn(nextButton, 'focus');
313-
314-
focusFirstInteractiveElement(container);
315-
expect(backSpy).not.toHaveBeenCalled();
316-
expect(nextSpy).toHaveBeenCalled();
317-
});
318-
319-
it('should return false when the only focusable element is the back button', () => {
320-
const backButton = document.createElement('button');
321-
backButton.id = 'backButton';
322-
const container = createContainer(backButton);
323-
324-
expect(focusFirstInteractiveElement(container)).toBe(false);
325-
});
326-
327306
it('should skip elements inside an [inert] subtree', () => {
328307
const inertWrapper = document.createElement('div');
329308
inertWrapper.setAttribute('inert', '');

0 commit comments

Comments
 (0)