Skip to content
This repository was archived by the owner on Feb 3, 2026. It is now read-only.

Commit 4469ef1

Browse files
authored
fix: added prop & check for readonly status of the document (#109)
* fix: added prop & check for readonly status of the document * added missing dependancy
1 parent 9ebc4c7 commit 4469ef1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/components/InternationalizedArray.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ export type InternationalizedArrayProps = ArrayOfObjectsInputProps<
3030
export default function InternationalizedArray(
3131
props: InternationalizedArrayProps
3232
): React.ReactElement {
33-
const {members, value, schemaType, onChange} = props
33+
const {
34+
members,
35+
value,
36+
schemaType,
37+
onChange,
38+
readOnly: documentReadOnly,
39+
} = props
3440

3541
const readOnly =
3642
typeof schemaType.readOnly === 'boolean' ? schemaType.readOnly : false
@@ -118,7 +124,9 @@ export default function InternationalizedArray(
118124
.filter((language) => !addedLanguages.includes(language))
119125
.filter((language) => languages.find((l) => l.id === language))
120126
// Account for strict mode by scheduling the update
121-
const timeout = setTimeout(() => handleAddLanguage(languagesToAdd))
127+
const timeout = setTimeout(() => {
128+
if (!documentReadOnly) handleAddLanguage(languagesToAdd)
129+
})
122130
return () => clearTimeout(timeout)
123131
}
124132
return undefined
@@ -129,6 +137,7 @@ export default function InternationalizedArray(
129137
defaultLanguages,
130138
addedLanguages,
131139
languages,
140+
documentReadOnly,
132141
])
133142

134143
// NOTE: This is reordering and re-setting the whole array, it could be surgical

0 commit comments

Comments
 (0)