Skip to content

Feature/optimize editor performance - #7793

Merged
martinjagodic merged 19 commits into
decaporg:mainfrom
laikacms:feature/optimize-editor-performance
Sep 22, 2026
Merged

martinjagodic merged 19 commits into
decaporg:mainfrom
laikacms:feature/optimize-editor-performance

Conversation

@sempostma

Copy link
Copy Markdown
Contributor

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:

  shouldComponentUpdate(nextProps, nextState) {
    const valuesThatWhereUpdated = []
    for (const key in nextProps) {
      if (this.props[key] !== nextProps[key]) {
        valuesThatWhereUpdated.push(key)
      }
    }

    const stateValuesThatWhereUpdated = []
    for (const key in nextState) {
      if (this.state[key] !== nextState[key]) {
        stateValuesThatWhereUpdated.push(key)
      }
    }

    console.log('EditorControl shouldComponentUpdate', {
      valuesThatWhereUpdated,
      stateValuesThatWhereUpdated,
    })

    return true;
  }

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)

Clueless

@sempostma
sempostma requested a review from a team as a code owner April 23, 2026 15:16
@sempostma sempostma mentioned this pull request Apr 23, 2026
1 task done

@yanthomasdev yanthomasdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 yanthomasdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a few things doing another pass here, let me know if they make sense!

@sempostma
sempostma force-pushed the feature/optimize-editor-performance branch from 7ffee68 to 5a4c351 Compare May 23, 2026 11:12
@sempostma

Copy link
Copy Markdown
Contributor Author

I found a few things doing another pass here, let me know if they make sense!

Nice, I made some changes and rebased the branch.

@sempostma
sempostma requested a review from yanthomasdev June 2, 2026 09:07

@yanthomasdev yanthomasdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@netlify

netlify Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for decap-cms ready!

Name Link
🔨 Latest commit d8fee3d
🔍 Latest deploy log https://app.netlify.com/projects/decap-cms/deploys/6ab13b017aaf3a0008185865
😎 Deploy Preview https://deploy-preview-7793--decap-cms.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sempostma
sempostma requested a review from yanthomasdev August 30, 2026 11:53

@yanthomasdev yanthomasdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 yanthomasdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Could you just rebase so we exclude all these commits that aren't really part of the changes done here?

sempostma and others added 2 commits September 14, 2026 11:46
Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
@sempostma
sempostma force-pushed the feature/optimize-editor-performance branch from 26cb2ef to d8fee3d Compare September 21, 2026 14:11
@sempostma

Copy link
Copy Markdown
Contributor Author

LGTM! Could you just rebase so we exclude all these commits that aren't really part of the changes done here?

Done!

@martinjagodic
martinjagodic merged commit b994417 into decaporg:main Sep 22, 2026
14 checks passed
martinjagodic pushed a commit that referenced this pull request Sep 22, 2026
* 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>
martinjagodic added a commit that referenced this pull request Oct 8, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants