Skip to content

Commit

Permalink
fix(input): allow type to be overwritten by user
Browse files Browse the repository at this point in the history
  • Loading branch information
McTom234 committed Jan 30, 2024
1 parent 81211e9 commit 021f0cd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cmdk/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type GroupProps = Children &
/** Whether this group is forcibly rendered regardless of filtering. */
forceMount?: boolean
}
type InputProps = Omit<React.ComponentPropsWithoutRef<typeof Primitive.input>, 'value' | 'onChange' | 'type'> & {
type InputProps = Omit<React.ComponentPropsWithoutRef<typeof Primitive.input>, 'value' | 'onChange'> & {
/**
* Optional controlled state for the value of the search input.
*/
Expand Down Expand Up @@ -762,7 +762,7 @@ const Separator = React.forwardRef<HTMLDivElement, SeparatorProps>((props, forwa
* All props are forwarded to the underyling `input` element.
*/
const Input = React.forwardRef<HTMLInputElement, InputProps>((props, forwardedRef) => {
const { onValueChange, ...etc } = props
const { onValueChange, type, ...etc } = props
const isControlled = props.value != null
const store = useStore()
const search = useCmdk((state) => state.search)
Expand All @@ -785,6 +785,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>((props, forwardedRe
return (
<Primitive.input
ref={forwardedRef}
type="text"
{...etc}
cmdk-input=""
autoComplete="off"
Expand All @@ -797,7 +798,6 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>((props, forwardedRe
aria-labelledby={context.labelId}
aria-activedescendant={selectedItemId}
id={context.inputId}
type="text"
value={isControlled ? props.value : search}
onChange={(e) => {
if (!isControlled) {
Expand Down

0 comments on commit 021f0cd

Please sign in to comment.