update search input styles

This commit is contained in:
jeffvli
2025-10-11 02:35:21 -07:00
parent b4d6bddcd6
commit cddf80c284
@@ -1,5 +1,5 @@
import { useHotkeys } from '@mantine/hooks'; import { useHotkeys } from '@mantine/hooks';
import { ChangeEvent, KeyboardEvent, useRef } from 'react'; import { ChangeEvent, KeyboardEvent, useRef, useState } from 'react';
import { shallow } from 'zustand/shallow'; import { shallow } from 'zustand/shallow';
import { useSettingsStore } from '/@/renderer/store'; import { useSettingsStore } from '/@/renderer/store';
@@ -35,14 +35,21 @@ export const SearchInput = ({ onChange, ...props }: SearchInputProps) => {
} }
}; };
const [isFocused, setIsFocused] = useState(false);
const hasValue = props.value || ref.current?.value;
return ( return (
<TextInput <TextInput
leftSection={<Icon icon="search" />} leftSection={<Icon icon="search" />}
maw="20dvw"
onBlur={() => setIsFocused(false)}
onChange={onChange} onChange={onChange}
onFocus={() => setIsFocused(true)}
onKeyDown={handleEscape} onKeyDown={handleEscape}
ref={ref} ref={ref}
size="sm" size="sm"
width={200} width={isFocused || hasValue ? '200px' : '100px'}
{...props} {...props}
rightSection={ rightSection={
ref.current?.value ? ( ref.current?.value ? (