Skip to content

Commit

Permalink
feat(ui): unselect multiselection on click - WF-148
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Dec 19, 2024
1 parent 21ecc92 commit 4cc8151
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/ui/src/builder/BuilderApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,14 @@ function handleRendererClick(ev: PointerEvent): void {
ev.preventDefault();
ev.stopPropagation();
if (ev.shiftKey || ev.ctrlKey) {
ssbm.appendSelection(targetId, targetInstancePath, "click");
if (!ev.shiftKey && !ev.ctrlKey) {
return ssbm.setSelection(targetId, targetInstancePath, "click");
}
if (ssbm.isComponentIdSelected(targetId)) {
ssbm.removeSelectedComponentId(targetId);
} else {
ssbm.setSelection(targetId, targetInstancePath, "click");
ssbm.appendSelection(targetId, targetInstancePath, "click");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/src/builder/builderManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export function generateBuilderManager() {

const removeSelectedComponentId = (componentId: string) => {
const newSelection = state.value.selection.filter(
(c) => c.componentId === componentId,
(c) => c.componentId !== componentId,
);
if (newSelection.length === state.value.selection.length) return;
state.value.selection = newSelection;
Expand Down
12 changes: 9 additions & 3 deletions src/ui/src/builder/sidebar/BuilderSidebarComponentTreeBranch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,17 @@ const name = computed(() => {
async function select(ev: MouseEvent | KeyboardEvent) {
goToComponentParentPage(props.componentId);
await nextTick();
if (ev.ctrlKey || ev.shiftKey) {
wfbm.appendSelection(props.componentId, undefined, "tree");
if (!ev.shiftKey && !ev.ctrlKey) {
return wfbm.setSelection(props.componentId, undefined, "tree");
}
if (wfbm.isComponentIdSelected(props.componentId)) {
wfbm.removeSelectedComponentId(props.componentId);
} else {
wfbm.setSelection(props.componentId, undefined, "tree");
wfbm.appendSelection(props.componentId, undefined, "tree");
}
expand();
}
Expand Down

0 comments on commit 4cc8151

Please sign in to comment.