From 1930f5e0347261c7d1277881ed473d00cdeeab4e Mon Sep 17 00:00:00 2001 From: gosangam Date: Tue, 5 May 2026 02:20:53 +0530 Subject: [PATCH] test: floating text selection toolbar --- components/text-selection-toolbar.tsx | 53 +++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/components/text-selection-toolbar.tsx b/components/text-selection-toolbar.tsx index a9bb238b..839980e8 100644 --- a/components/text-selection-toolbar.tsx +++ b/components/text-selection-toolbar.tsx @@ -710,12 +710,47 @@ function MorePopover({ function FloatingToolbar({ position, actions, + isMobile, }: { position: Position; actions: ToolbarAction[]; + isMobile: boolean; }) { - // Calculate position — center above the selection, clamp to viewport - const toolbarWidth = actions.length * 44 + 8; // approximate + if (isMobile) { + // Mobile: fixed bottom bar + return createPortal( +
e.preventDefault()} + > +
+ {actions.map((action) => ( + + ))} +
+
, + document.body, + ); + } + + // Desktop: floating above the selection + const toolbarWidth = actions.length * 44 + 8; const left = Math.max( 8, Math.min( @@ -727,9 +762,9 @@ function FloatingToolbar({ return createPortal(
e.preventDefault()} // prevent losing selection + onMouseDown={(e) => e.preventDefault()} > {actions.map((action) => ( ))}
, @@ -1008,7 +1043,11 @@ export function TextSelectionToolbar() { return (
{/* Floating toolbar */} - + {/* More popover */}