-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
Undo/redo through different views #1417
Conversation
6837de4
to
a1fe951
Compare
…urrent view info (initial setup)
@@ -965,83 +955,138 @@ export default function RenderOverlay({ canvasHostRef }: RenderOverlayProps) { | |||
const isDraggingOverLayoutSlot = dragOverSlot?.type === 'layout'; | |||
const isDraggingOverElement = appDom.isElement(dragOverNode); | |||
|
|||
domApi.update((draft) => { | |||
let parent = appDom.getParent(draft, dragOverNode); | |||
domApi.update( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all just formatting changes except the second argument passed to domApi.update
(which caused the reformatting). Maybe I should extract this nested function...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great effort!
This should be good to merge, will merge soon if there's no more feedback. |
Switches to the correct view on undo/redo.
Also closes #1460.
Video (undo starts at 1:36):
Screen.Recording.2022-12-20.at.13.56.17.mov
Preview URL: https://toolpad-pr-1417.onrender.com/
Summary of changes:
domApi
to set current view and tab. View can also be changed withdomApi.update
if we want 1 action to represent a DOM change + view change, for example, which was needed in some situations.There's many different approaches we could use for this logic and to extend/improve it. I think this a good starting point for further changes, even if it's not the final solution.
(Also we might still be able to use DOM diffs to get the current view automatically, just starting out with something simpler)
Continuing to follow the checklist in #226
Relevant discussion reference: #1225 (comment)