From 020b00e10f0bf627e26c967076414bf1656264fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20ROU=C3=8BN=C3=89?= Date: Mon, 8 Jul 2024 16:36:34 +0200 Subject: [PATCH] [3710] Fix an error raised by switching mode on portal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://github.com/eclipse-sirius/sirius-web/issues/3710 Signed-off-by: Florian ROUËNÉ --- CHANGELOG.adoc | 1 + .../src/renderer/palette/DiagramElementPalette.tsx | 14 +++++++------- .../src/renderer/palette/DiagramPalette.tsx | 7 ++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 0b42e0960c..a50d302964 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -77,6 +77,7 @@ More existing APIs will be migrated to this new common pattern. - https://github.com/eclipse-sirius/sirius-web/issues/3709[#3709] [domain] Add a conditional edge style for containment references - https://github.com/eclipse-sirius/sirius-web/issues/3722[#3722] [sirius-web] Fix reference widget registration - https://github.com/eclipse-sirius/sirius-web/issues/3711[#3711] [diagram] Fix an issue that prevent filter elements button to be in read-only mode +- https://github.com/eclipse-sirius/sirius-web/issues/3710[#3710] [portal] Fix an error raised by switching mode on portal === New Features diff --git a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/DiagramElementPalette.tsx b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/DiagramElementPalette.tsx index 8dfdc6c234..220292076e 100644 --- a/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/DiagramElementPalette.tsx +++ b/packages/diagrams/frontend/sirius-components-diagrams/src/renderer/palette/DiagramElementPalette.tsx @@ -26,6 +26,13 @@ export const DiagramElementPalette = memo(({ diagramElementId, labelId }: Diagra const { isOpened, x, y, hideDiagramElementPalette } = useDiagramElementPalette(); const { setCurrentlyEditedLabelId, currentlyEditedLabelId } = useDiagramDirectEdit(); + const escapePressed = useKeyPress('Escape'); + useEffect(() => { + if (escapePressed) { + hideDiagramElementPalette(); + } + }, [escapePressed, hideDiagramElementPalette]); + if (readOnly) { return null; } @@ -36,13 +43,6 @@ export const DiagramElementPalette = memo(({ diagramElementId, labelId }: Diagra } }; - const escapePressed = useKeyPress('Escape'); - useEffect(() => { - if (escapePressed) { - hideDiagramElementPalette(); - } - }, [escapePressed, hideDiagramElementPalette]); - return isOpened && x && y && !currentlyEditedLabelId ? ( { const { readOnly } = useContext(DiagramContext); const { isOpened, x, y, hideDiagramPalette } = useDiagramPalette(); - if (readOnly) { - return null; - } const escapePressed = useKeyPress('Escape'); useEffect(() => { @@ -34,6 +31,10 @@ export const DiagramPalette = memo(({ diagramElementId }: DiagramPaletteProps) = } }, [escapePressed, hideDiagramPalette]); + if (readOnly) { + return null; + } + return isOpened && x && y ? ( {}} />