@@ -169,6 +169,8 @@ export interface TagInputProps extends VariantProps<typeof tagInputVariants> {
169169 onAdd : ( value : string ) => boolean
170170 /** Callback when a tag is removed (receives value, index, and isValid) */
171171 onRemove : ( value : string , index : number , isValid : boolean ) => void
172+ /** Callback when the input value changes (useful for clearing errors) */
173+ onInputChange ?: ( value : string ) => void
172174 /** Placeholder text for the input */
173175 placeholder ?: string
174176 /** Placeholder text when there are existing tags */
@@ -210,6 +212,7 @@ const TagInput = React.forwardRef<HTMLInputElement, TagInputProps>(
210212 items,
211213 onAdd,
212214 onRemove,
215+ onInputChange,
213216 placeholder = 'Enter values' ,
214217 placeholderWithTags = 'Add another' ,
215218 disabled = false ,
@@ -347,10 +350,12 @@ const TagInput = React.forwardRef<HTMLInputElement, TagInputProps>(
347350 } )
348351
349352 if ( addedCount === 0 && pastedValues . length === 1 ) {
350- setInputValue ( inputValue + pastedValues [ 0 ] )
353+ const newValue = inputValue + pastedValues [ 0 ]
354+ setInputValue ( newValue )
355+ onInputChange ?.( newValue )
351356 }
352357 } ,
353- [ onAdd , inputValue ]
358+ [ onAdd , inputValue , onInputChange ]
354359 )
355360
356361 const handleBlur = React . useCallback ( ( ) => {
@@ -425,7 +430,10 @@ const TagInput = React.forwardRef<HTMLInputElement, TagInputProps>(
425430 name = { name }
426431 type = 'text'
427432 value = { inputValue }
428- onChange = { ( e ) => setInputValue ( e . target . value ) }
433+ onChange = { ( e ) => {
434+ setInputValue ( e . target . value )
435+ onInputChange ?.( e . target . value )
436+ } }
429437 onKeyDown = { handleKeyDown }
430438 onPaste = { handlePaste }
431439 onBlur = { handleBlur }
0 commit comments