[base-ui][Autocomplete] Implement undo / redo#35636
[base-ui][Autocomplete] Implement undo / redo#35636hbjORbj wants to merge 5 commits intomui:masterfrom
Conversation
@material-ui/core: parsed: +0.15% , gzip: +0.17% |
| import isEqual from 'lodash/isEqual'; | ||
| import { useState } from 'react'; | ||
|
|
||
| const useUndoAndRedo = <T>(initialValue?: T) => { |
There was a problem hiding this comment.
We may want to add an option about how many steps in the history we want to keep.
Did you remove it by deleting text or by clicking "X" button? In my case, if I remove via clicking "X" button and then undo, all works as expected, but if I remove via deleting text a bug and then undo, I experience the same bug as you did. |
There was a problem hiding this comment.
I couldn't test the behavior because I have an azerty keyboard. I have left a comment on how to fix this.
Otherwise, I struggle to find end-user traction for this behavior. For example, JedWatson/react-select#168 has little activity, I couldn't find something on select2, bootstrap, and I couldn't find anything else when I search on Google. So I'm not entirely sure that we should build this feature, maybe this has a too high opportunity cost compared to our options?
But Gmail has it :) Should I open an issue and wait for upvotes? |
|
It's a nice quality-of-life feature! I agree that perhaps there isn't a big market for it, though.
Whenever you are in the middle of the undo stack and make an edit, you should disregard any items above the current item in the stack. There's also some weird behavior in the free solo mode - when I select items from the list and enter my own ones, the ones outside the list are not taken into consideration for the undo stack. |
It's simply that it's not all free, e.g. it has a bundle size cost: If we don't move forward, I think that such issue would be a great next step. Something I wonder about is: How does the undo shortcut fits when the app also has such logic, e.g. Toolpad? There needs to be a way to not handle the event twice. I guess it can be solved with either an |


Follow-up on #35545 (comment)
This PR contains:
useUndoAndRedouseUndoAndRedoinuseAutocompleteBefore:
After: