Skip to content
This repository was archived by the owner on Feb 3, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/components/InternationalizedArray.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export type InternationalizedArrayProps = ArrayOfObjectsInputProps<
export default function InternationalizedArray(
props: InternationalizedArrayProps
): React.ReactElement {
const {members, value, schemaType, onChange} = props
const {
members,
value,
schemaType,
onChange,
readOnly: documentReadOnly,
} = props

const readOnly =
typeof schemaType.readOnly === 'boolean' ? schemaType.readOnly : false
Expand Down Expand Up @@ -118,7 +124,9 @@ export default function InternationalizedArray(
.filter((language) => !addedLanguages.includes(language))
.filter((language) => languages.find((l) => l.id === language))
// Account for strict mode by scheduling the update
const timeout = setTimeout(() => handleAddLanguage(languagesToAdd))
const timeout = setTimeout(() => {
if (!documentReadOnly) handleAddLanguage(languagesToAdd)
})
return () => clearTimeout(timeout)
}
return undefined
Expand All @@ -129,6 +137,7 @@ export default function InternationalizedArray(
defaultLanguages,
addedLanguages,
languages,
documentReadOnly,
])

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