@@ -166,6 +166,8 @@ export interface TagInputProps extends VariantProps<typeof tagInputVariants> {
166166 onAdd : ( value : string ) => boolean
167167 /** Callback when a tag is removed (receives value, index, and isValid) */
168168 onRemove : ( value : string , index : number , isValid : boolean ) => void
169+ /** Callback when the input value changes (useful for clearing errors) */
170+ onInputChange ?: ( value : string ) => void
169171 /** Placeholder text for the input */
170172 placeholder ?: string
171173 /** Placeholder text when there are existing tags */
@@ -207,6 +209,7 @@ const TagInput = React.forwardRef<HTMLInputElement, TagInputProps>(
207209 items,
208210 onAdd,
209211 onRemove,
212+ onInputChange,
210213 placeholder = 'Enter values' ,
211214 placeholderWithTags = 'Add another' ,
212215 disabled = false ,
@@ -344,10 +347,12 @@ const TagInput = React.forwardRef<HTMLInputElement, TagInputProps>(
344347 } )
345348
346349 if ( addedCount === 0 && pastedValues . length === 1 ) {
347- setInputValue ( inputValue + pastedValues [ 0 ] )
350+ const newValue = inputValue + pastedValues [ 0 ]
351+ setInputValue ( newValue )
352+ onInputChange ?.( newValue )
348353 }
349354 } ,
350- [ onAdd , inputValue ]
355+ [ onAdd , inputValue , onInputChange ]
351356 )
352357
353358 const handleBlur = React . useCallback ( ( ) => {
@@ -422,7 +427,10 @@ const TagInput = React.forwardRef<HTMLInputElement, TagInputProps>(
422427 name = { name }
423428 type = 'text'
424429 value = { inputValue }
425- onChange = { ( e ) => setInputValue ( e . target . value ) }
430+ onChange = { ( e ) => {
431+ setInputValue ( e . target . value )
432+ onInputChange ?.( e . target . value )
433+ } }
426434 onKeyDown = { handleKeyDown }
427435 onPaste = { handlePaste }
428436 onBlur = { handleBlur }
0 commit comments