Skip to content

Commit

Permalink
[3710] Fix an error raised by switching mode on portal
Browse files Browse the repository at this point in the history
Bug: eclipse-sirius#3710
Signed-off-by: Florian ROUËNÉ <[email protected]>
  • Loading branch information
frouene authored and sbegaudeau committed Jul 9, 2024
1 parent cb39718 commit 020b00e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 ? (
<PalettePortal>
<Palette
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ import { useDiagramPalette } from './useDiagramPalette';
export const DiagramPalette = memo(({ diagramElementId }: DiagramPaletteProps) => {
const { readOnly } = useContext<DiagramContextValue>(DiagramContext);
const { isOpened, x, y, hideDiagramPalette } = useDiagramPalette();
if (readOnly) {
return null;
}

const escapePressed = useKeyPress('Escape');
useEffect(() => {
Expand All @@ -34,6 +31,10 @@ export const DiagramPalette = memo(({ diagramElementId }: DiagramPaletteProps) =
}
}, [escapePressed, hideDiagramPalette]);

if (readOnly) {
return null;
}

return isOpened && x && y ? (
<PalettePortal>
<Palette x={x} y={y} diagramElementId={diagramElementId} onDirectEditClick={() => {}} />
Expand Down

0 comments on commit 020b00e

Please sign in to comment.