From fdfb49758148bd104dfd8dec753793e762c372b0 Mon Sep 17 00:00:00 2001 From: spereirag Date: Tue, 19 Dec 2023 13:15:49 -0300 Subject: [PATCH] fix: avoid unnecessary rerenders (#7004) * fix: avoid unnecessary rerenders while assets are loading * fix: formatting --------- Co-authored-by: spereirag Co-authored-by: Anze Demsar --- .../src/components/Editor/EditorControlPane/EditorControl.js | 2 ++ .../src/components/Editor/EditorControlPane/Widget.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js index 3c146b741fd2..87ff6aefae88 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js +++ b/packages/decap-cms-core/src/components/Editor/EditorControlPane/EditorControl.js @@ -204,6 +204,7 @@ class EditorControl extends React.Component { parentIds, t, validateMetaField, + isLoadingAsset, isDisabled, isHidden, isFieldDuplicate, @@ -329,6 +330,7 @@ class EditorControl extends React.Component { isDisabled={isDisabled} isFieldDuplicate={isFieldDuplicate} isFieldHidden={isFieldHidden} + isLoadingAsset={isLoadingAsset} locale={locale} /> {fieldHint && ( diff --git a/packages/decap-cms-core/src/components/Editor/EditorControlPane/Widget.js b/packages/decap-cms-core/src/components/Editor/EditorControlPane/Widget.js index 827d434f466c..953065a10c7d 100644 --- a/packages/decap-cms-core/src/components/Editor/EditorControlPane/Widget.js +++ b/packages/decap-cms-core/src/components/Editor/EditorControlPane/Widget.js @@ -75,6 +75,10 @@ export default class Widget extends Component { }; shouldComponentUpdate(nextProps) { + /** + * Avoid unnecessary rerenders while loading assets. + */ + if (this.props.isLoadingAsset) return false; /** * Allow widgets to provide their own `shouldComponentUpdate` method. */