Ability to disable "undo" / adjust undo duration
Is your feature request related to a problem? Please describe. The "undo" feature in react-admin is highly misleading to users given that it is not actually an undo.
Undo traditionally means "the change happened, undo the change." React-admin's implementation is instead a delay in making API calls. This subtle difference is confusing to both users and developers.
Our admin users are finding this default behavior problematic: it slows down their editing workflow, it can cause unexpected results if they leave the page, refresh, or otherwise, etc.
Describe the solution you'd like For our app, we want to globally disable the undo feature. I want to be able to set a configuration value that sets undo duration to 0 (this config value could also be used to extend or decrease the duration for other use cases).
Describe alternatives you've considered I know you can create your own edit components and pass it around, but this requires all our developers to remember one trivial detail (import edit from our file instead of react-admin). If a developer forgets to import our custom Edit button (say, they're following react-admin documentation that describes importing Edit from react-admin), then we have different behavior for one component.
Instead I think a better implementation is for react-admin to accept configuration related to this behavior. Simply accept an undo duration value that can be set to 0 to disable the feature. Users may want to increase, decrease, or disable the duration of the undo functionality - this supports all cases and is backwards compatible.
Additional context Furthermore, I would strongly suggest that this functionality be renamed (per several other reported issues) given that its behavior is so misleading.
About the duration customization, this is explained in the documentation.
If you disagree with the undo term from end users, you can provide your own translations (eg: Cancel maybe?).
Disabling the feature is possible by creating your own components as you already know and we don't want to provide more options on the Admin component.
I'll leave the issue open until another core member either confirm my point or agree to implement this option. Ping @fzaninotto
@djhi Appreciate the quick response.
The docs you linked to solves a different problem. I don't want to change how long the notification box is open. I want to disable "undo" by setting its duration to 0 - but I still want the notification to appear for 4 seconds. Really, two different functionalities. Please correct me if I am wrong.
I do disagree with the terminology and am simply providing feedback and suggesting to the R-A team that you consider renaming it to avoid confusion for future users. I understand that I can rename it internally in my project.
we don't want to provide more options on the Admin component
I find this hard to understand. What is wrong with adding additional configurability to this project?
The workaround (creating my own component) makes the library more tedious to work with, as opposed to simply configuring one number to match how I want it to behave. Why not aim to make the library more flexible and configurable, especially for controversial and opinionated functionality?
I would be happy to submit a pull request implementing this functionality if you guys would accept it?
One of the core design decisions for react-admin is to avoid a central configuration in favor of swappable components. We've come the first route with ng-admin, our previous iteration at a frontend admin generator, and we've hit strong limitations. On the other hand, allowing to swap one component for another allows for a complete customization, in a natural way. We're happy with that design decision, and we want to stick to it.
If you find it tedious to replace a react-admin component by your own, I can suggest two options:
- create an eslint rule that detects imports of the Edit component from react-admin, and warns to use your variation instead
- create your own distribution of react-admin (i.e. an alternative npm package), with components overridden to match your needs. You can even do that without renaming imports in the code - just by using the package.json resolutions.
Because it's not that hard to do any of the previous changes, we won't add a central configuration for the undo feature.
As for renaming it, you're not the first one to complain about the confusion. We can probably do a better job at explaining it to developers. But I think the end-user feature should still be named "undo" - that's what the feature actually does. And if the feature name is "undo" for end users, I believe it should have the same name in the developer docs.
Got it, thank you again for the thorough response and appreciate the perspective regarding the design decision of swappable components vs configurability.
The library has provided amazing bang for the buck, thanks for creating it!