-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
warnWhenUnsavedChanges
does not function properly with disabled TextInput
#9378
Comments
Thanks for the report, we will flag it as a bug |
Probably same root cause as issue #9365, i.e. react-hook-form/react-hook-form#11055. To be confirmed, but if that is the case, then there's nothing we can do (apart from fixing the demo). |
The analysis is confirmed. The issue can be solved it by adding The demo will be updated shortly to implement just that. |
What would be the workaround for an |
@lvernaillen You can use <AutocompleteInput
optionText="name"
fullWidth
TextFieldProps={{ InputProps: { disabled: true } }}
/> |
@slax57 did try your solution, but the input is not disabled. you can check here (autocomplete field for adding authors) https://stackblitz.com/edit/github-mjvobu?file=src%2Fposts%2FPostCreate.tsx,src%2Fposts%2FPostEdit.tsx |
@tyeremenko I don't see any |
Edit: I wrote to fast, after other tests it seems |
@slax57 I used the Here is a stackblitz where I added a simple https://stackblitz.com/edit/github-6a8auj?file=src%2Fposts%2FPostEdit.tsx |
@adguernier Can you share the steps you did?
So, the question remains. How to disable an |
@lvernaillen You're right! I can suggest the following workaround however: use <AutocompleteInput readOnly /> If that still does not suit your needs, then feel free to open a new issue (specific to |
Thanks for your reply. I will look into using Meanwhile I noticed the same issue with If |
What you were expecting:
If you open the editing page for any resource and then leave that page without making any changes, you should not be prompted with an alert for unsaved changes.
What happened instead:
When you open the edit page for the Posts or Comments resource and then leave that page without making any modifications, an alert for unsaved changes IS shown.
Steps to reproduce:
The Comments resource has the same issue. However, this problem doesn't impact tag editing.
Related code:
Standard sample application on stackblitz.com is enough to reproduce the bug:
Other information:
It appears that this bug is associated with the
disabled
attribute of theTextInput
component. After removing thedisabled
attribute on lines 119 and 227 in thesrc/posts/PostEdit.tsx
file, no unnecessary alerts are displayed.When the
disabled
attribute is present, the alert is triggered even if no modifications to the record have been made. You can confirm that no modifications have been made by observing the disabled state of theSAVE
button.The Tags resource is functioning correctly, probably because there are no disabled text inputs.
Environment
The text was updated successfully, but these errors were encountered: