Skip to content

feat: add onEmpty callback to Command#400

Open
stevysmith wants to merge 1 commit intodip:mainfrom
stevysmith:feat/on-empty-callback
Open

feat: add onEmpty callback to Command#400
stevysmith wants to merge 1 commit intodip:mainfrom
stevysmith:feat/on-empty-callback

Conversation

@stevysmith
Copy link

Summary

  • Adds onEmpty prop to Command — an event handler called when the search query produces no results
  • Fires with the current search string, only when there's a non-empty query and zero matching items
  • Follows the existing callback pattern (onValueChange, onSelect) using optional chaining via propsRef

Motivation

There's no way to react programmatically when filtering produces zero results. Command.Empty handles the visual side, but there's no behavioral hook for the event itself. This is useful for:

  • Analytics — capture unmatched queries to understand what users are looking for
  • AI fallback — trigger an alternative search or AI-powered response when results are empty
  • Feedback collection — prompt users to submit a request when their search yields nothing

Usage

<Command
  onEmpty={(search) => {
    console.log('No results for', search)
  }}
/>

Event handler called when the search query produces no results.
Useful for analytics, triggering AI fallback, or capturing unmet
user intent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant