mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-17 19:24:30 +01:00
fix active tool type
This commit is contained in:
@@ -200,7 +200,9 @@ export const MobileToolBar = ({
|
|||||||
(tool) => tool.type === app.defaultSelectionTool,
|
(tool) => tool.type === app.defaultSelectionTool,
|
||||||
) || SELECTION_TOOLS[0]
|
) || SELECTION_TOOLS[0]
|
||||||
}
|
}
|
||||||
isActive={(type: string) => type === "lasso" || type === "selection"}
|
isActive={
|
||||||
|
activeTool.type === "selection" || activeTool.type === "lasso"
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Free Draw */}
|
{/* Free Draw */}
|
||||||
@@ -257,9 +259,7 @@ export const MobileToolBar = ({
|
|||||||
SHAPE_TOOLS.find((tool) => tool.type === lastActiveGenericShape) ||
|
SHAPE_TOOLS.find((tool) => tool.type === lastActiveGenericShape) ||
|
||||||
SHAPE_TOOLS[0]
|
SHAPE_TOOLS[0]
|
||||||
}
|
}
|
||||||
isActive={(type: string) =>
|
isActive={["rectangle", "diamond", "ellipse"].includes(activeTool.type)}
|
||||||
["rectangle", "diamond", "ellipse"].includes(type)
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Arrow/Line */}
|
{/* Arrow/Line */}
|
||||||
@@ -288,7 +288,7 @@ export const MobileToolBar = ({
|
|||||||
(tool) => tool.type === lastActiveLinearElement,
|
(tool) => tool.type === lastActiveLinearElement,
|
||||||
) || LINEAR_ELEMENT_TOOLS[0]
|
) || LINEAR_ELEMENT_TOOLS[0]
|
||||||
}
|
}
|
||||||
isActive={(type: string) => ["arrow", "line"].includes(type)}
|
isActive={["arrow", "line"].includes(activeTool.type)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Image */}
|
{/* Image */}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ type ToolWithPopupProps = {
|
|||||||
"data-testid": string;
|
"data-testid": string;
|
||||||
onToolChange: (type: string) => void;
|
onToolChange: (type: string) => void;
|
||||||
getDisplayedOption: () => ToolOption;
|
getDisplayedOption: () => ToolOption;
|
||||||
isActive: (type: string) => boolean;
|
isActive: boolean;
|
||||||
fillable?: boolean;
|
fillable?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -154,7 +154,6 @@ export const ToolWithPopup = ({
|
|||||||
const [triggerRef, setTriggerRef] = useState<HTMLElement | null>(null);
|
const [triggerRef, setTriggerRef] = useState<HTMLElement | null>(null);
|
||||||
|
|
||||||
const displayedOption = getDisplayedOption();
|
const displayedOption = getDisplayedOption();
|
||||||
const isToolActive = options.some((option) => isActive(option.type));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ position: "relative" }}>
|
<div style={{ position: "relative" }}>
|
||||||
@@ -163,7 +162,7 @@ export const ToolWithPopup = ({
|
|||||||
className={clsx(className, { fillable })}
|
className={clsx(className, { fillable })}
|
||||||
type="radio"
|
type="radio"
|
||||||
icon={displayedOption.icon}
|
icon={displayedOption.icon}
|
||||||
checked={isToolActive}
|
checked={isActive}
|
||||||
name="editor-current-shape"
|
name="editor-current-shape"
|
||||||
title={title}
|
title={title}
|
||||||
aria-label={title}
|
aria-label={title}
|
||||||
|
|||||||
Reference in New Issue
Block a user