press enter invite

This commit is contained in:
Nate Kelley 2025-04-21 14:33:49 -06:00
parent 62d13729fb
commit f53bc01955
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 7 additions and 0 deletions

View File

@ -59,6 +59,7 @@ export const InvitePeopleModal: React.FC<{
<InputTagInput <InputTagInput
tags={emails} tags={emails}
onChangeText={setInputText} onChangeText={setInputText}
onPressEnter={handleInvite}
onTagAdd={(v) => { onTagAdd={(v) => {
const arrayedTags = Array.isArray(v) ? v : [v]; const arrayedTags = Array.isArray(v) ? v : [v];
const hadMultipleTags = arrayedTags.length > 1; const hadMultipleTags = arrayedTags.length > 1;

View File

@ -12,6 +12,7 @@ export interface TagInputProps extends VariantProps<typeof inputVariants> {
onTagAdd?: (tag: string | string[]) => void; onTagAdd?: (tag: string | string[]) => void;
onTagRemove?: (index: number) => void; onTagRemove?: (index: number) => void;
onChangeText?: (text: string) => void; onChangeText?: (text: string) => void;
onPressEnter?: () => void;
placeholder?: string; placeholder?: string;
disabled?: boolean; disabled?: boolean;
maxTags?: number; maxTags?: number;
@ -29,6 +30,7 @@ const InputTagInput = React.forwardRef<HTMLInputElement, TagInputProps>(
onTagAdd, onTagAdd,
onTagRemove, onTagRemove,
onChangeText, onChangeText,
onPressEnter,
placeholder, placeholder,
disabled = false, disabled = false,
maxTags, maxTags,
@ -80,6 +82,10 @@ const InputTagInput = React.forwardRef<HTMLInputElement, TagInputProps>(
} else if (e.key === 'Backspace' && inputValue === '' && tags.length > 0 && !disabled) { } else if (e.key === 'Backspace' && inputValue === '' && tags.length > 0 && !disabled) {
onTagRemove?.(tags.length - 1); onTagRemove?.(tags.length - 1);
} }
if (e.key === 'Enter' && inputValue.trim() === '') {
onPressEnter?.();
}
}); });
const handleInputChange = useMemoizedFn((e: React.ChangeEvent<HTMLInputElement>) => { const handleInputChange = useMemoizedFn((e: React.ChangeEvent<HTMLInputElement>) => {