Skip to content

Commit 7183b24

Browse files
authored
fix(core): skip updating focusPath state if unchanged (#7524)
1 parent e102679 commit 7183b24

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
type SanityDocumentLike,
99
} from '@sanity/types'
1010
import {useToast} from '@sanity/ui'
11-
import {fromString as pathFromString, resolveKeyedPath} from '@sanity/util/paths'
11+
import {fromString as pathFromString, pathFor, resolveKeyedPath} from '@sanity/util/paths'
1212
import {omit, throttle} from 'lodash'
1313
import {memo, useCallback, useEffect, useMemo, useRef, useState} from 'react'
1414
import deepEquals from 'react-fast-compare'
@@ -615,10 +615,11 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => {
615615
)
616616

617617
const handleFocus = useCallback(
618-
(nextFocusPath: Path, payload?: OnPathFocusPayload) => {
619-
setFocusPath(nextFocusPath)
620-
if (!deepEquals(focusPathRef.current, nextFocusPath)) {
621-
setOpenPath(nextFocusPath.slice(0, -1))
618+
(_nextFocusPath: Path, payload?: OnPathFocusPayload) => {
619+
const nextFocusPath = pathFor(_nextFocusPath)
620+
if (nextFocusPath !== focusPathRef.current) {
621+
setFocusPath(pathFor(nextFocusPath))
622+
setOpenPath(pathFor(nextFocusPath.slice(0, -1)))
622623
focusPathRef.current = nextFocusPath
623624
onFocusPath?.(nextFocusPath)
624625
}

0 commit comments

Comments
 (0)