fix active tool type

This commit is contained in:
Ryan Di
2025-09-19 00:53:15 +10:00
parent d28b63fcbb
commit 4492c81fa8
2 changed files with 7 additions and 8 deletions

View File

@@ -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 */}

View File

@@ -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<HTMLElement | null>(null);
const displayedOption = getDisplayedOption();
const isToolActive = options.some((option) => isActive(option.type));
return (
<div style={{ position: "relative" }}>
@@ -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}