Change AsyncSelect to load search history on initial mount

- Use empty query for initial load
- Remove value dependency from effect
- Always show search history first
- Simplify initialization logic
This commit is contained in:
yangdx 2025-09-20 14:17:08 +08:00
parent 9330ccb14e
commit da30529585

View file

@ -133,8 +133,8 @@ export function AsyncSelect<T>({
try { try {
setLoading(true) setLoading(true)
setError(null) setError(null)
// If we have a value, use it for the initial search // Always use empty query for initial load to show search history
const data = await fetcher(value) const data = await fetcher('')
setOriginalOptions(data) setOriginalOptions(data)
setOptions(data) setOptions(data)
} catch (err) { } catch (err) {
@ -147,7 +147,7 @@ export function AsyncSelect<T>({
if (!mounted) { if (!mounted) {
initializeOptions() initializeOptions()
} }
}, [mounted, fetcher, value]) }, [mounted, fetcher])
useEffect(() => { useEffect(() => {
const fetchOptions = async () => { const fetchOptions = async () => {