fix(ui): processing and initializing form does not disable standalone fields (#11714)
The form component's `initializing` and `processing` states do not disable fields that are rendered outside of `DocumentFields`. Fields currently rely on the `readOnly` prop provided by `DocumentFields` and do not subscribe to these states for themselves. This means that fields that are rendered outright, such as within the bulk edit drawer, they do not receive a `readOnly` prop and are therefore never disabled. The fix is add a `disabled` property to the `useField` hook. This subscribes to the `initializing` and `processing` states in the same way as `DocumentFields`, however, now each field can determine its own disabled state instead of relying solely on the `readOnly` prop. Adding this new prop has no overhead as `processing` and `initializing` is already being subscribed to within `useField`.
This commit is contained in:
@@ -95,7 +95,7 @@ const RichTextField: React.FC<LoadedSlateFieldProps> = (props) => {
|
||||
|
||||
const {
|
||||
customComponents: { Description, Error, Label } = {},
|
||||
formInitializing,
|
||||
disabled: disabledFromField,
|
||||
initialValue,
|
||||
setValue,
|
||||
showError,
|
||||
@@ -105,7 +105,7 @@ const RichTextField: React.FC<LoadedSlateFieldProps> = (props) => {
|
||||
validate: memoizedValidate,
|
||||
})
|
||||
|
||||
const disabled = readOnlyFromProps || formInitializing
|
||||
const disabled = readOnlyFromProps || disabledFromField
|
||||
|
||||
const editor = useMemo(() => {
|
||||
let CreatedEditor = withEnterBreakOut(withHistory(withReact(createEditor())))
|
||||
|
||||
Reference in New Issue
Block a user