Skip to content

Commit 350b567

Browse files
binoy14bjoerge
andcommittedMay 3, 2023
fix(core): focus first descendant in FormView when empty initial focus path is given
Co-authored-by: Bjørge Næss <bjoerge@gmail.com> Co-authored-by: Binoy Patel <me@binoy.io>
1 parent ec31040 commit 350b567

File tree

1 file changed

+8
-2
lines changed
  • packages/sanity/src/desk/panes/document/documentPanel/documentViews

1 file changed

+8
-2
lines changed
 

‎packages/sanity/src/desk/panes/document/documentPanel/documentViews/FormView.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,14 @@ export function FormView(props: FormViewProps) {
106106
const formRef = useRef<null | HTMLDivElement>(null)
107107

108108
useEffect(() => {
109-
focusFirstDescendant(formRef.current!)
110-
}, [])
109+
// Only focus on the first descendant if there is not already a focus path
110+
// This is to avoid stealing focus from intent links
111+
if (ready && !formState?.focusPath.length) {
112+
focusFirstDescendant(formRef.current!)
113+
}
114+
// We only want to run it on first mount
115+
// eslint-disable-next-line react-hooks/exhaustive-deps
116+
}, [ready])
111117

112118
// const after = useMemo(
113119
// () =>

0 commit comments

Comments
 (0)
Failed to load comments.