Prevent cmdk querying after selection is made

This commit is contained in:
Sam Becker 2024-03-14 11:43:36 -05:00
parent 5214d76f46
commit e3cd0e59cd

View File

@ -97,7 +97,7 @@ export default function CommandKClient({
}, [setIsOpen]); }, [setIsOpen]);
useEffect(() => { useEffect(() => {
if (queryDebounced.length >= MINIMUM_QUERY_LENGTH) { if (queryDebounced.length >= MINIMUM_QUERY_LENGTH && !isPending) {
setIsLoading(true); setIsLoading(true);
onQueryChange?.(queryDebounced).then(querySections => { onQueryChange?.(queryDebounced).then(querySections => {
if (isOpenRef.current) { if (isOpenRef.current) {
@ -109,7 +109,7 @@ export default function CommandKClient({
setIsLoading(false); setIsLoading(false);
}); });
} }
}, [queryDebounced, onQueryChange]); }, [queryDebounced, onQueryChange, isPending]);
useEffect(() => { useEffect(() => {
if (queryLive === '') { if (queryLive === '') {
@ -182,7 +182,7 @@ export default function CommandKClient({
placeholder="Search photos, views, settings ..." placeholder="Search photos, views, settings ..."
disabled={isPending} disabled={isPending}
/> />
{isLoading && {isLoading && !isPending &&
<span className={clsx( <span className={clsx(
'absolute top-2.5 right-0 w-8', 'absolute top-2.5 right-0 w-8',
'flex items-center justify-center translate-y-[2px]', 'flex items-center justify-center translate-y-[2px]',