Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3595] Only update the selection when it really changes
Browse files Browse the repository at this point in the history
Bug: #3595
Signed-off-by: Pierre-Charles David <[email protected]>
pcdavid committed Jun 7, 2024
1 parent 1e35688 commit afdf9eb
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@
- https://github.com/eclipse-sirius/sirius-web/issues/3529[#3529] [diagram] Improve edge path when a layout direction is defined
- https://github.com/eclipse-sirius/sirius-web/issues/3489[#3489] [diagram] Apply a fit to screen after an arrange all
- https://github.com/eclipse-sirius/sirius-web/issues/3548[#3548] [core] Avoid costly recomputations in MigrationService
- https://github.com/eclipse-sirius/sirius-web/issues/3595[#3595] [core] Avoid re-rendering the workbench when the selection does not really change

== v2024.5.0

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* Copyright (c) 2023, 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
@@ -32,7 +32,21 @@ export const SelectionContextProvider = ({ initialSelection, children }: Selecti
});

const setSelection = useCallback((selection: Selection) => {
setState((prevState) => ({ ...prevState, selection }));
setState((prevState) => {
const prevSelectionKey = prevState.selection?.entries
.map((entry) => entry.id)
.sort()
.join(':');
const newSelectionKey = selection?.entries
.map((entry) => entry.id)
.sort()
.join(':');
if (prevSelectionKey !== newSelectionKey) {
return { ...prevState, selection };
} else {
return prevState;
}
});
}, []);

return (

0 comments on commit afdf9eb

Please sign in to comment.