Skip to content

Fix support for readOnly on all RA Inputs#9656

Merged
slax57 merged 58 commits intomasterfrom
readOnly-for-all-inputs
Mar 1, 2024
Merged

Fix support for readOnly on all RA Inputs#9656
slax57 merged 58 commits intomasterfrom
readOnly-for-all-inputs

Conversation

@erwanMarmelab
Copy link
Contributor

@erwanMarmelab erwanMarmelab commented Feb 9, 2024

Problem

Since a recent change in react-hook-form v7.47.0, warnWhenUnsavedChanges does not function properly with disabled inputs. The alternative is to use readOnly, but issue #9498 highlighted that not all our inputs support the readOnly prop. For instance, <ArrayInput> is still modifiable even with this prop. Also, MUI renders readOnly inputs just like regular inputs, and this is confusing for end users who can't modify the value with no visual cue.

Solution

When a developer passes readOnly, we pass readOnly to useInput and disabled to MUI.

Note that some inputs may not yet support readOnly or disabled

Out of scope

Fix the style of the inputs to make it clear that inputs with readOnly cannot be changed → this can be done in user-land (with sx for now)

Todos

Input Story Prop
ArrayInput
AutoCompleteInput
AutoCompleteArrayInput
BooleanInput
NullabeBooleanInput
CheckboxGroupInput
DateInput
DateTimeInput
FileInput
ImageInput
NumberInput
PasswordInput
RadioButtonGroupInput
ReferenceInput
ReferenceArrayInput
RichTextInput
SearchInput
SelectInput
SelectArrayInput
SimpleFormIterator
TextInput
TimeInput
TranslatableInput

@erwanMarmelab erwanMarmelab added RFR Ready For Review WIP Work In Progress and removed RFR Ready For Review labels Feb 9, 2024
@erwanMarmelab erwanMarmelab changed the title add all stories Fix support for readOnly on all RA Inputs Feb 12, 2024
Copy link
Contributor

@slax57 slax57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 🎉 🎉

kudos team!! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RFR Ready For Review

Development

Successfully merging this pull request may close these issues.

5 participants