From 5132bce0a1433ea0f26e13d9b52ff6718c9b3b9e Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Tue, 4 Nov 2025 14:16:34 +1100 Subject: [PATCH] tool bar fixes: icon and width --- .../excalidraw/components/MobileToolBar.tsx | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/excalidraw/components/MobileToolBar.tsx b/packages/excalidraw/components/MobileToolBar.tsx index bc52c01b71..0d2f909f53 100644 --- a/packages/excalidraw/components/MobileToolBar.tsx +++ b/packages/excalidraw/components/MobileToolBar.tsx @@ -101,8 +101,6 @@ export const MobileToolBar = ({ "arrow" | "line" >("arrow"); - const toolbarRef = useRef(null); - // keep lastActiveGenericShape in sync with active tool if user switches via other UI useEffect(() => { if ( @@ -143,8 +141,8 @@ export const MobileToolBar = ({ } }; - const toolbarWidth = - toolbarRef.current?.getBoundingClientRect()?.width ?? 0 - 8; + const [toolbarWidth, setToolbarWidth] = useState(0); + const WIDTH = 36; const GAP = 4; @@ -164,6 +162,9 @@ export const MobileToolBar = ({ "laser", "magicframe", ].filter((tool) => { + if (showTextToolOutside && tool === "text") { + return false; + } if (showImageToolOutside && tool === "image") { return false; } @@ -174,21 +175,30 @@ export const MobileToolBar = ({ }); const extraToolSelected = extraTools.includes(activeTool.type); const extraIcon = extraToolSelected - ? activeTool.type === "frame" + ? activeTool.type === "text" + ? TextIcon + : activeTool.type === "image" + ? ImageIcon + : activeTool.type === "frame" ? frameToolIcon : activeTool.type === "embeddable" ? EmbedIcon : activeTool.type === "laser" ? laserPointerToolIcon - : activeTool.type === "text" - ? TextIcon : activeTool.type === "magicframe" ? MagicIcon : extraToolsIcon : extraToolsIcon; return ( -
+
{ + if (div) { + setToolbarWidth(div.getBoundingClientRect().width); + } + }} + > {/* Hand Tool */}