-
Notifications
You must be signed in to change notification settings - Fork 12
fix(editor): commit temporary actions to history only after resolving them #4252
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📦 Next.js Bundle Analysis for @serlo/frontendThis analysis was generated by the Next.js Bundle Analysis action. 🤖
|
| Page | Size (compressed) |
|---|---|
global |
104.42 KB (🟡 +1 B) |
Details
The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.
Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis
If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!
Seven Pages Changed Size
The following pages changed size from the code in this PR compared to its base branch:
| Page | Size (compressed) | First Load |
|---|---|---|
/___editor_preview |
530.25 KB (-5 B) |
634.67 KB |
/entity/create/[type]/[taxonomyId] |
550.34 KB (-5 B) |
654.75 KB |
/entity/repository/add-revision/[...id] |
550.07 KB (-5 B) |
654.49 KB |
/page/create |
550.06 KB (-5 B) |
654.48 KB |
/taxonomy/term/create/[parent_id]/[id] |
549.81 KB (-5 B) |
654.23 KB |
/taxonomy/term/update/[id] |
549.76 KB (-5 B) |
654.17 KB |
/user/settings |
551.75 KB (-5 B) |
656.17 KB |
Details
Only the gzipped size is provided here based on an expert tip.
First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.
Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis
Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.
elbotho
left a comment
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.
👍 thank you for the deep dive!
Not sure I would have figured that one out.
LarsTheGlidingSquirrel
left a comment
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.
I don't know enough about the relevant code but I tested the editor and performed a lot of undo/redo and found no issue.
Thank you for looking into this and finding a solution!
Resolves #4241
Note: First commit is only cleaning up, second commit fixes the bug.
This took way longer to figure out than I'd like to admit 😬
The editor emits
onChangeevents when actions are committed to history, not when actions are resolved.For most changes, this doesn't matter, as we first resolve actions, then commit them to history.
There are, however, these "temporary" actions, used in
asyncScalar. One use-case ofasyncScalaris uploading an image, where we had the bug. And in these "temporary" actions, we were first committing actions to history, then resolving them, which led the editor to emitonChangebefore its state was updated.I snooped around the code to see if I could find any reason for this difference between regular and "temporary" actions, and I couldn't find any. I also tested the editor, and everything seems to work fine, but it would be great if you could test a bit as well.
Explanation for "temporary" actions (
asyncScalar): I believe these were initially created to support loading states of async actions. So once a user uploads an image, a temporary action would show a loading screen, and then a normal action would show the uploaded image and the temporary action would be removed from history. That would make sure that undo/redo works as expected -- never showing the loading screen. I couldn't figure out how to use this, though. Either the feature was never finished, or we broke it unknowingly.@elbotho This also fixes the ___editor_preview -- the right side will now show the image as soon as it's uploaded.