From d29c8e7d329a5f3cf475a1367ee2c34ac4e691cd Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Wed, 23 Jul 2025 17:00:38 +1000 Subject: [PATCH] render according to default selection tool --- packages/excalidraw/components/Actions.tsx | 39 ++++++++++++++++------ 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/packages/excalidraw/components/Actions.tsx b/packages/excalidraw/components/Actions.tsx index 919e9c688d..fb0c32e3d1 100644 --- a/packages/excalidraw/components/Actions.tsx +++ b/packages/excalidraw/components/Actions.tsx @@ -63,6 +63,7 @@ import { laserPointerToolIcon, MagicIcon, LassoIcon, + LassoIconMobile, } from "./icons"; import type { AppClassProperties, AppProps, UIAppState, Zoom } from "../types"; @@ -295,15 +296,31 @@ export const ShapesSwitcher = ({ const frameToolSelected = activeTool.type === "frame"; const laserToolSelected = activeTool.type === "laser"; - const lassoToolSelected = activeTool.type === "lasso"; + const lassoToolSelected = + activeTool.type === "lasso" && app.defaultSelectionTool !== "lasso"; const embeddableToolSelected = activeTool.type === "embeddable"; const { TTDDialogTriggerTunnel } = useTunnels(); + // we'll need to update SHAPES to swap lasso and selection + const _SHAPES = + app.defaultSelectionTool === "lasso" + ? ([ + { + value: "lasso", + icon: LassoIconMobile, + key: KEYS.L, + numericKey: KEYS["1"], + fillable: true, + }, + ...SHAPES.slice(1), + ] as const) + : SHAPES; + return ( <> - {SHAPES.map(({ value, icon, key, numericKey, fillable }, index) => { + {_SHAPES.map(({ value, icon, key, numericKey, fillable }, index) => { if ( UIOptions.tools?.[ value as Extract @@ -418,14 +435,16 @@ export const ShapesSwitcher = ({ > {t("toolBar.laser")} - app.setActiveTool({ type: "lasso" })} - icon={LassoIcon} - data-testid="toolbar-lasso" - selected={lassoToolSelected} - > - {t("toolBar.lasso")} - + {app.defaultSelectionTool !== "lasso" && ( + app.setActiveTool({ type: "lasso" })} + icon={LassoIcon} + data-testid="toolbar-lasso" + selected={lassoToolSelected} + > + {t("toolBar.lasso")} + + )}
Generate