From aed70f624fc8c0c5dbc000b9457988789af1d4cc Mon Sep 17 00:00:00 2001 From: Joshua Swigut <62301576+JJSwigut@users.noreply.github.com> Date: Fri, 4 Apr 2025 16:43:03 -0400 Subject: [PATCH] (bug-fix: 1984) Update search highlighter to use overlay (#2035) --- ui/desktop/eslint.config.js | 4 + ui/desktop/src/components/ChatView.tsx | 2 +- .../src/components/conversation/SearchBar.tsx | 13 +- .../components/conversation/SearchView.tsx | 144 ++++--- ui/desktop/src/styles/search.css | 5 +- ui/desktop/src/utils/searchHighlighter.ts | 365 +++++++++++++++--- 6 files changed, 380 insertions(+), 153 deletions(-) diff --git a/ui/desktop/eslint.config.js b/ui/desktop/eslint.config.js index d1422cd7..4ce023c5 100644 --- a/ui/desktop/eslint.config.js +++ b/ui/desktop/eslint.config.js @@ -86,6 +86,10 @@ module.exports = [ React: 'readonly', handleAction: 'readonly', requestAnimationFrame: 'readonly', + ResizeObserver: 'readonly', + MutationObserver: 'readonly', + NodeFilter: 'readonly', + Text: 'readonly', }, }, plugins: { diff --git a/ui/desktop/src/components/ChatView.tsx b/ui/desktop/src/components/ChatView.tsx index 9973dee6..cd2599c8 100644 --- a/ui/desktop/src/components/ChatView.tsx +++ b/ui/desktop/src/components/ChatView.tsx @@ -388,7 +388,7 @@ export default function ChatView({ /> ) : ( - + {filteredMessages.map((message, index) => (
{isUserMessage(message) ? ( diff --git a/ui/desktop/src/components/conversation/SearchBar.tsx b/ui/desktop/src/components/conversation/SearchBar.tsx index a52a05e5..4fd5bebb 100644 --- a/ui/desktop/src/components/conversation/SearchBar.tsx +++ b/ui/desktop/src/components/conversation/SearchBar.tsx @@ -51,18 +51,17 @@ export const SearchBar: React.FC = ({ const handleKeyDown = (event: KeyboardEvent) => { if (event.key === 'ArrowUp') { - event.preventDefault(); - onNavigate?.('prev'); + handleNavigate('prev', event); } else if (event.key === 'ArrowDown') { - event.preventDefault(); - onNavigate?.('next'); + handleNavigate('next', event); } else if (event.key === 'Escape') { event.preventDefault(); handleClose(); } }; - const handleNavigate = (direction: 'next' | 'prev') => { + const handleNavigate = (direction: 'next' | 'prev', e?: React.MouseEvent | KeyboardEvent) => { + e?.preventDefault(); onNavigate?.(direction); inputRef.current?.focus(); }; @@ -123,7 +122,7 @@ export const SearchBar: React.FC = ({