diff --git a/web/src/hooks/use-auto-resize-textarea.ts b/web/src/hooks/use-auto-resize-textarea.ts index cd9f0fcfe2..74e57720f4 100644 --- a/web/src/hooks/use-auto-resize-textarea.ts +++ b/web/src/hooks/use-auto-resize-textarea.ts @@ -15,6 +15,12 @@ export function useAutoResizeTextarea( const el = ref.current; if (!el) return; el.style.height = 'auto'; + // scrollHeight excludes borders while height is border-box, so the + // content box ends up a couple of pixels short and overflow-y-auto + // would show a scrollbar even for a single line. Hide it until the + // content actually exceeds the max height. + const overflowing = el.scrollHeight > maxHeight; + el.style.overflowY = overflowing ? 'auto' : 'hidden'; el.style.height = `${Math.min(el.scrollHeight, maxHeight)}px`; }, [ref, value, maxHeight]); } diff --git a/web/src/pages/next-search/search-home.tsx b/web/src/pages/next-search/search-home.tsx index 317cca2d50..0cc481b243 100644 --- a/web/src/pages/next-search/search-home.tsx +++ b/web/src/pages/next-search/search-home.tsx @@ -35,7 +35,7 @@ export default function SearchHome({
-
+
{!isSearching && }
{!isSearching && ( @@ -56,7 +56,7 @@ export default function SearchHome({ ref={searchInputRef} rows={1} placeholder={t('search.searchGreeting')} - className="w-full rounded-3xl py-4 px-4 pr-14 text-text-primary text-lg bg-bg-base delay-700 border border-border-button resize-none overflow-y-auto scrollbar-thin outline-none focus-visible:ring-1 focus-visible:ring-text-primary/50" + className="w-full rounded-3xl py-4 px-4 pr-14 text-text-primary text-lg bg-bg-base delay-700 border border-border-button resize-none scrollbar-thin outline-none focus-visible:ring-1 focus-visible:ring-text-primary/50" value={searchText} onKeyDown={(e) => { if ( @@ -82,7 +82,7 @@ export default function SearchHome({ />
diff --git a/web/src/pages/next-search/search-view.tsx b/web/src/pages/next-search/search-view.tsx index 8c0aa34250..bfa1a09b3a 100644 --- a/web/src/pages/next-search/search-view.tsx +++ b/web/src/pages/next-search/search-view.tsx @@ -111,7 +111,7 @@ export default function SearchingView({ rows={1} placeholder={t('search.searchGreeting')} className={cn( - 'w-full rounded-3xl py-4 pl-4 !pr-[8rem] text-primary text-lg bg-bg-base border border-border-button resize-none overflow-y-auto scrollbar-thin outline-none focus-visible:ring-1 focus-visible:ring-text-primary/50 disabled:cursor-not-allowed disabled:opacity-50', + 'w-full rounded-3xl py-4 pl-4 !pr-[8rem] text-primary text-lg bg-bg-base border border-border-button resize-none scrollbar-thin outline-none focus-visible:ring-1 focus-visible:ring-text-primary/50 disabled:cursor-not-allowed disabled:opacity-50', )} value={searchText} onChange={(e) => { @@ -129,19 +129,21 @@ export default function SearchingView({ } }} /> -
- { - setSearchText(''); - handleClickRelatedQuestion(''); - }} - /> - | +
+ {searchText && ( + { + setSearchText(''); + handleClickRelatedQuestion(''); + }} + /> + )} +
@@ -333,14 +334,12 @@ export default function SearchingView({ )}
{mindMapVisible && ( -
- -
+ )}