Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for readOnly on all RA Inputs #9656

Merged
merged 58 commits into from
Mar 1, 2024
Merged

Conversation

erwanMarmelab
Copy link
Contributor

@erwanMarmelab erwanMarmelab commented Feb 9, 2024

Problem

Since a recent change in react-hook-form, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants