Skip to content

Commit

Permalink
feat: add default value prop (#123)
Browse files Browse the repository at this point in the history
* feat: add default value prop

* fix: revert example

* fix: check for undefined toLowerCase

* fix: prettier test format
  • Loading branch information
revogabe authored May 3, 2023
1 parent 0d74730 commit bbcc8cf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmdk/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ type CommandProps = Children &
* By default, uses the `command-score` library.
*/
filter?: (value: string, search: string) => number
/**
* Optional default item value when it is initially rendered.
*/
defaultValue?: string
/**
* Optional controlled state of the selected command menu item.
*/
Expand Down Expand Up @@ -137,7 +141,7 @@ const Command = React.forwardRef<HTMLDivElement, CommandProps>((props, forwarded
/** Value of the search query. */
search: '',
/** Currently selected item value. */
value: props.value ?? '',
value: props.value ?? props.defaultValue?.toLowerCase() ?? '',
filtered: {
/** The count of all visible items. */
count: 0,
Expand Down

1 comment on commit bbcc8cf

@vercel
Copy link

@vercel vercel bot commented on bbcc8cf May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

cmdk-website – ./

cmdk-website-git-main-paco.vercel.app
cmdk.vercel.app
cmdk-website-paco.vercel.app
cmdk.paco.me

Please sign in to comment.