From 9f7818bccdc24d394a64a6e159ad93108391eaa1 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Fri, 14 Jul 2023 11:12:21 +0200 Subject: [PATCH 1/2] Refactor componentDidUpdate in DragAndDrop --- src/components/DragAndDrop/index.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/components/DragAndDrop/index.js b/src/components/DragAndDrop/index.js index 694904007ae7..bbc95ca43ced 100644 --- a/src/components/DragAndDrop/index.js +++ b/src/components/DragAndDrop/index.js @@ -64,19 +64,11 @@ class DragAndDrop extends React.Component { } componentDidUpdate(prevProps) { - if (this.props.isFocused !== prevProps.isFocused) { - if (!this.props.isFocused) { - this.removeEventListeners(); - } else { - this.addEventListeners(); - } - } - const isDisabled = this.props.disabled; - if (isDisabled === prevProps.disabled) { + if (this.props.isFocused === prevProps.isFocused || isDisabled === prevProps.disabled) { return; } - if (isDisabled) { + if (!this.props.isFocused || isDisabled) { this.removeEventListeners(); } else { this.addEventListeners(); From a56019aa13fb9c2fb2b366df5f7c080a91652e23 Mon Sep 17 00:00:00 2001 From: Jakub Kosmydel <104823336+kosmydel@users.noreply.github.com> Date: Fri, 14 Jul 2023 11:15:22 +0200 Subject: [PATCH 2/2] Fix the operator --- src/components/DragAndDrop/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/DragAndDrop/index.js b/src/components/DragAndDrop/index.js index bbc95ca43ced..5c5d17a4a272 100644 --- a/src/components/DragAndDrop/index.js +++ b/src/components/DragAndDrop/index.js @@ -65,7 +65,7 @@ class DragAndDrop extends React.Component { componentDidUpdate(prevProps) { const isDisabled = this.props.disabled; - if (this.props.isFocused === prevProps.isFocused || isDisabled === prevProps.disabled) { + if (this.props.isFocused === prevProps.isFocused && isDisabled === prevProps.disabled) { return; } if (!this.props.isFocused || isDisabled) {