Skip to content

Commit 841ea75

Browse files
authored
fix: use tabster to focus on trigger, instead of manually invoking .focus (#27512)
1 parent d0b0d09 commit 841ea75

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "fix: use tabster to focus on trigger, instead of manually invoking .focus",
4+
"packageName": "@fluentui/react-dialog",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/react-dialog/src/utils/useFocusFirstElement.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ export function useFocusFirstElement(open: boolean, modalType: DialogModalType)
1111
const { findFirstFocusable } = useFocusFinders();
1212
const { targetDocument } = useFluent_unstable();
1313
const dialogRef = React.useRef<DialogSurfaceElement>(null);
14-
const triggerRef = React.useRef<HTMLElement>();
1514

1615
React.useEffect(() => {
1716
if (!open) {
18-
return triggerRef.current?.focus();
17+
return;
1918
}
20-
triggerRef.current = targetDocument?.activeElement as HTMLElement | undefined;
2119
const element = dialogRef.current && findFirstFocusable(dialogRef.current);
2220
if (element) {
2321
element.focus();

0 commit comments

Comments
 (0)