-
Notifications
You must be signed in to change notification settings - Fork 0
Add type prop to Select searchInputProps #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,15 +30,25 @@ const CommandDialog = ({ children, ...props }: CommandDialogProps) => { | |
| ); | ||
| }; | ||
|
|
||
| const CommandInput = ({ className, ...props }: React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>) => ( | ||
| type CommandInputProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input> & { | ||
| type?: React.InputHTMLAttributes<HTMLInputElement>['type']; | ||
| }; | ||
|
|
||
| const CommandInput = ({ className, type = 'text', ...props }: CommandInputProps) => ( | ||
| <div className="flex items-center border-b px-3" cmdk-input-wrapper=""> | ||
| <CommandPrimitive.Input | ||
| className={cn( | ||
| 'flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50', | ||
| className, | ||
| )} | ||
| {...props} | ||
| /> | ||
| {/* | ||
| To override the type of the input, we couldn't apply the type attribute to the CommandPrimitive.Input component b/c it's hardcoded as 'text' in the cmdk library | ||
| Reference: https://github.com/pacocoursey/cmdk/blob/main/cmdk/src/index.tsx#L816 | ||
| */} | ||
| <CommandPrimitive.Input asChild {...props}> | ||
| <input | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lcmohsen why do we need asChild and input here? Is CommandPrimitive.Input not already an input?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The input type is hardcoded in https://github.com/pacocoursey/cmdk/blob/main/cmdk/src/index.tsx |
||
| type={type} | ||
| className={cn( | ||
| 'flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50', | ||
| className, | ||
| )} | ||
| /> | ||
| </CommandPrimitive.Input> | ||
| </div> | ||
| ); | ||
|
|
||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Export the CommandInputProps type.
The type definition follows the correct naming convention, but it should be exported for external use and better type safety when composing components.
As per coding guidelines: "Always export both the component and its props type"
Apply this diff to export the type:
📝 Committable suggestion
🤖 Prompt for AI Agents