From 0cb835021d1156d1e857058e28787f47d0396e8a Mon Sep 17 00:00:00 2001 From: mcharfadi Date: Wed, 28 Aug 2024 12:07:52 +0200 Subject: [PATCH] [3899] Fix nodesDraggable staying false MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://github.com/eclipse-sirius/sirius-web/issues/3899 Signed-off-by: Michaƫl Charfadi --- CHANGELOG.adoc | 1 + .../src/renderer/drag/useNodesDraggable.ts | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 3d1d5fe3a74..232e1e3327c 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -78,6 +78,7 @@ As a result, the following maven modules have been deleted: `sirius-web-sample-a - https://github.com/eclipse-sirius/sirius-web/issues/3849[#3849] [form] Fix the tree representation in form support the display of the same referenced element many times in the tree. - https://github.com/eclipse-sirius/sirius-web/issues/3878[#3878] [diagram] Unmount ReactFlowProvider after layout - https://github.com/eclipse-sirius/sirius-web/issues/3869[#3869] [form] Close form-based views when the underlying element no longer exists. +- https://github.com/eclipse-sirius/sirius-web/issues/3899[#3899] [diagram] Fix an issue when using alt-tab shortcut and trying to drag a node afterwards === New Features diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/drag/useNodesDraggable.ts b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/drag/useNodesDraggable.ts index 6c38cb30859..10eaca58fc2 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/drag/useNodesDraggable.ts +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/drag/useNodesDraggable.ts @@ -34,9 +34,15 @@ export const useNodesDraggable = (): UseNodesDraggableValue => { }; document.addEventListener('keyup', keyupListener); + const onBlurListener = () => { + setState((prevState) => ({ ...prevState, nodesDraggable: true })); + }; + document.addEventListener('blur', onBlurListener); + return () => { document.removeEventListener('keydown', keydownListener); document.removeEventListener('keyup', keyupListener); + document.removeEventListener('blur', onBlurListener); }; }, []);