diff --git a/app/components/float-buttons-panel.tsx b/app/components/float-buttons-panel.tsx index 92c56bf..b8851bc 100644 --- a/app/components/float-buttons-panel.tsx +++ b/app/components/float-buttons-panel.tsx @@ -195,7 +195,7 @@ export function FloatButtonsPanel({ )} ), - [showAIPanel], + [showAIPanel, selectedText], ); return createPortal(panel, document.body); diff --git a/app/hooks/use-select-to-search.tsx b/app/hooks/use-select-to-search.tsx index 33fc63b..8d9a2e3 100644 --- a/app/hooks/use-select-to-search.tsx +++ b/app/hooks/use-select-to-search.tsx @@ -57,10 +57,12 @@ const useSelectToSearch = ({ ? generateWordSuggestionPrompt : prompt; + const selectedText = selection?.toString().trim() || ""; + const panel = showPanel ? ( selection!.getRangeAt(0).getBoundingClientRect()} - selectedText={selection!.toString().trim()} + selectedText={selectedText} showSearch={showSearch} showCopy={showCopy} showAI={showAI}