Repository navigation
Feature/optimize editor performance - #7793
Conversation
yanthomasdev
left a comment
There was a problem hiding this comment.
Thanks @sempostma, CI is failing because you need to do npm run format in your branch, I would've done that for you but apparently I can't commit to your branch 😓
yanthomasdev
left a comment
There was a problem hiding this comment.
I found a few things doing another pass here, let me know if they make sense!
7ffee68 to
5a4c351
Compare
Nice, I made some changes and rebased the branch. |
yanthomasdev
left a comment
There was a problem hiding this comment.
Thanks @sempostma, one small comment and I believe it should be good to go. I just need you to update branch here since the branch is protected and I can't do it myself
✅ Deploy Preview for decap-cms ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
yanthomasdev
left a comment
There was a problem hiding this comment.
Hey @sempostma, the branch seems to be in a dirty state right now, could you take a look and fix the merge conflicts? Thanks!
yanthomasdev
left a comment
There was a problem hiding this comment.
LGTM! Could you just rebase so we exclude all these commits that aren't really part of the changes done here?
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…e/EditorControl.js Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
…e/EditorControl.js Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
26cb2ef to
d8fee3d
Compare
Done! |
* feat: memoize the boundGetAsset function * feat: make parent ids stable * feat: make each child onChange callback stable and also made parentIds stable * feat: optimize editor control components and widgets * feat: fixed the last violating unstable component * fix: remove performance logging comments * refactor: code formatting * Update packages/decap-cms-widget-object/src/ObjectControl.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: resolver Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix: code and memoization issues * fix: bad memoization cache key * fix: editor control issues * fix: typo on deprecation comment * Update packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com> * Update packages/decap-cms-core/src/actions/media.ts Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com> * Update packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com> * fix: small refactor * fix: missing return statement Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com> * test(widget-list): pass item key to handleChangeFor --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
EditorControlPane passed each control a fresh fieldActionContext object holding the whole entry, so connect's shallow prop check failed for every top-level field on every keystroke. That undid the memoization the editor performance work (#7793) relies on, and the entry in it was never read. EditorControl already has the collection and locale, and the action context now reads the entry only when an action asks for it, which also gives a click the current entry rather than the one from the last render. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Note
I had to close and ropen #7719 because I moved my decap-cms fork repository to an organization.
This PR simply prevents a rerender of the entire EditorControl tree. This is done by making all the props stable, aka not passing new references when its not needed.
The risk with this change is that it's very easy for someone to create a new commit that reintroduces in an unstable prop which would cause the same performance issues again.
Summary
I'm using Decap for a project with a very large collection schema with reorder-able blocks and lists. On a 2024's machine, typing is almost impossible so not acceptable as a deliverable.
Test plan
The best way to test it is adding a 'shouldComponentUpdate' to the editorControl:
If you add this to the current main branch, you will see hundreds of messages. After the change this drops to 3 or 4 (for each keystroke you type in a field for example).
Checklist
A picture of a cute animal (not mandatory but encouraged)