Skip to content

Commit 475b0eb

Browse files
committed
[6215] Automatically expand newly opened selection dialog to give more context
Bug: #6215 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
1 parent 523f186 commit 475b0eb

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

CHANGELOG.adoc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ The new template for functional specification is located in `doc/iterations/YYYY
4545
The technical specifications will now rely on a new architectural decision record template located in `doc/adrs/adr.adoc`.
4646
This new template for ADRs will have several additional requirements compared to the previous one.
4747
It will require contributors to specify the persons involved in the decision process, to details the qualities expected of the solution, to list the various options considered, to clarify why a specific option has been selected, its advantages and drawbacks, which steps will be taken for the implementation among other things.
48-
49-
48+
- https://github.com/eclipse-sirius/sirius-web/issues/6215[#6215] [diagram] When a tool opens a selection dialog to ask for input, the tree displayed in the dialog is now expanded to reveal the element on which the tool was invoked to provide better context.
5049

5150
== 2026.3.0
5251

@@ -203,8 +202,6 @@ Trees defined via the view DSL can alternatively provide a tooltip expression vi
203202
- https://github.com/eclipse-sirius/sirius-web/issues/6267[#6267] [sirius-web] Allow customizing the content of the Views Explorer via delegates.
204203
- https://github.com/eclipse-sirius/sirius-web/issues/6268[#6268] [sirius-web] Allow customizing the labels of the Views Explorer via delegates.
205204

206-
207-
208205
== 2026.1.0
209206

210207
=== Pitches

packages/selection/frontend/sirius-components-selection/src/SelectionDialogTreeView.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
TreeItemActionProps,
1818
TreeView,
1919
useExpandAllTreePath,
20+
useTreePath,
2021
} from '@eclipse-sirius/sirius-components-trees';
2122
import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore';
2223
import IconButton from '@mui/material/IconButton';
@@ -40,6 +41,7 @@ const useTreeStyle = makeStyles<{ hasSelection: boolean }>()((theme, { hasSelect
4041
const initialState: SelectionDialogTreeViewState = {
4142
expanded: [],
4243
maxDepth: 1,
44+
initialized: false,
4345
};
4446

4547
export const SelectionDialogTreeView = ({
@@ -51,6 +53,7 @@ export const SelectionDialogTreeView = ({
5153
}: SelectionDialogTreeViewProps) => {
5254
const { classes } = useTreeStyle({ hasSelection: selectedTreeItemIds.length !== 0 });
5355
const [state, setState] = useState<SelectionDialogTreeViewState>(initialState);
56+
const { getTreePath, data: treePathData } = useTreePath();
5457

5558
const treeId = `selection://?treeDescriptionId=${encodeURIComponent(treeDescriptionId)}${encodeVariables(variables)}`;
5659
const { tree } = useSelectionDialogTreeSubscription(editingContextId, treeId, state.expanded, state.maxDepth);
@@ -60,9 +63,30 @@ export const SelectionDialogTreeView = ({
6063
...prevState,
6164
expanded: newExpandedIds,
6265
maxDepth: Math.max(newMaxDepth, prevState.maxDepth),
66+
initialized: true,
6367
}));
6468
};
6569

70+
useEffect(() => {
71+
if (tree && !state.initialized) {
72+
var targetObjectId = variables.find((variable) => variable.name === 'targetObjectId')?.value as string;
73+
getTreePath({
74+
variables: {
75+
editingContextId,
76+
treeId: tree.id,
77+
selectionEntryIds: [targetObjectId],
78+
},
79+
});
80+
}
81+
}, [tree, state.initialized, variables]);
82+
83+
useEffect(() => {
84+
if (treePathData && treePathData.viewer?.editingContext?.treePath) {
85+
const { treeItemIdsToExpand, maxDepth } = treePathData.viewer.editingContext.treePath;
86+
onExpandedElementChange(treeItemIdsToExpand ?? [], maxDepth ?? 1);
87+
}
88+
}, [treePathData]);
89+
6690
return (
6791
<div className={classes.borderStyle}>
6892
{tree ? (

packages/selection/frontend/sirius-components-selection/src/SelectionDialogTreeView.types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2024, 2025 Obeo.
2+
* Copyright (c) 2024, 2026 Obeo.
33
* This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v2.0
55
* which accompanies this distribution, and is available at
@@ -24,4 +24,5 @@ export interface SelectionDialogTreeViewProps {
2424
export interface SelectionDialogTreeViewState {
2525
expanded: string[];
2626
maxDepth: number;
27+
initialized: boolean;
2728
}

0 commit comments

Comments
 (0)