From 4492c81fa8e50bb7bac1417d923bf0ab7fdef841 Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Fri, 19 Sep 2025 00:53:15 +1000 Subject: [PATCH] fix active tool type --- packages/excalidraw/components/MobileToolBar.tsx | 10 +++++----- packages/excalidraw/components/ToolWithPopup.tsx | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/excalidraw/components/MobileToolBar.tsx b/packages/excalidraw/components/MobileToolBar.tsx index 1bb488b8f..af3799e53 100644 --- a/packages/excalidraw/components/MobileToolBar.tsx +++ b/packages/excalidraw/components/MobileToolBar.tsx @@ -200,7 +200,9 @@ export const MobileToolBar = ({ (tool) => tool.type === app.defaultSelectionTool, ) || SELECTION_TOOLS[0] } - isActive={(type: string) => type === "lasso" || type === "selection"} + isActive={ + activeTool.type === "selection" || activeTool.type === "lasso" + } /> {/* Free Draw */} @@ -257,9 +259,7 @@ export const MobileToolBar = ({ SHAPE_TOOLS.find((tool) => tool.type === lastActiveGenericShape) || SHAPE_TOOLS[0] } - isActive={(type: string) => - ["rectangle", "diamond", "ellipse"].includes(type) - } + isActive={["rectangle", "diamond", "ellipse"].includes(activeTool.type)} /> {/* Arrow/Line */} @@ -288,7 +288,7 @@ export const MobileToolBar = ({ (tool) => tool.type === lastActiveLinearElement, ) || LINEAR_ELEMENT_TOOLS[0] } - isActive={(type: string) => ["arrow", "line"].includes(type)} + isActive={["arrow", "line"].includes(activeTool.type)} /> {/* Image */} diff --git a/packages/excalidraw/components/ToolWithPopup.tsx b/packages/excalidraw/components/ToolWithPopup.tsx index 1e4289f45..2df305c3d 100644 --- a/packages/excalidraw/components/ToolWithPopup.tsx +++ b/packages/excalidraw/components/ToolWithPopup.tsx @@ -132,7 +132,7 @@ type ToolWithPopupProps = { "data-testid": string; onToolChange: (type: string) => void; getDisplayedOption: () => ToolOption; - isActive: (type: string) => boolean; + isActive: boolean; fillable?: boolean; }; @@ -154,7 +154,6 @@ export const ToolWithPopup = ({ const [triggerRef, setTriggerRef] = useState(null); const displayedOption = getDisplayedOption(); - const isToolActive = options.some((option) => isActive(option.type)); return (
@@ -163,7 +162,7 @@ export const ToolWithPopup = ({ className={clsx(className, { fillable })} type="radio" icon={displayedOption.icon} - checked={isToolActive} + checked={isActive} name="editor-current-shape" title={title} aria-label={title}