chore: prevent leave without saving from appearing when not needed (#8200)
This commit is contained in:
@@ -8,15 +8,15 @@ type Props = {
|
|||||||
readOnly: boolean
|
readOnly: boolean
|
||||||
}
|
}
|
||||||
export function TenantFieldComponentClient({ initialValue, path, readOnly }: Props) {
|
export function TenantFieldComponentClient({ initialValue, path, readOnly }: Props) {
|
||||||
const { formInitializing, setValue } = useField({ path })
|
const { formInitializing, setValue, value } = useField({ path })
|
||||||
const hasSetInitialValue = React.useRef(false)
|
const hasSetInitialValue = React.useRef(false)
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!hasSetInitialValue.current && !formInitializing && initialValue) {
|
if (!hasSetInitialValue.current && !formInitializing && initialValue && !value) {
|
||||||
setValue(initialValue)
|
setValue(initialValue)
|
||||||
hasSetInitialValue.current = true
|
hasSetInitialValue.current = true
|
||||||
}
|
}
|
||||||
}, [initialValue, setValue, formInitializing])
|
}, [initialValue, setValue, formInitializing, value])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RelationshipField
|
<RelationshipField
|
||||||
|
|||||||
Reference in New Issue
Block a user