Dynamic commands based on user input
See original GitHub issueIs your feature request related to a problem? Please describe.
Currently I’m unable to generate commands dynamically based on the user’s query. For example, when the user types “my query”, I would like to include commands Search for "my query"
and Create file named "myQuery.txt"
.
Describe the solution you’d like
Ideally we’d have a mechanism to access the <input>
's value. A solution that comes to mind is allowing the commands
prop to also accept a (query: string) => object[]
callback, passing the user’s query as an argument.
Describe alternatives you’ve considered
Another solution could be exposing an inputRef
prop which gets forwarded the <input>
element, thus allowing the parent component to access the query directly via inputRef.current.value
. I dislike this approach as it exposes implementation details about the component. The input field will probably always be a bona fide <input>
, but still, providing the query via a callback seems superior.
I could probably use findDOMNode
to get a reference to the <input>
and regenerate the command array when the query changes, but obviously this is hacky and sad.
Happy to work on this. Or if this is possible already and I’m simply missing it, would love to know it.
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (11 by maintainers)
@mminer youre right, I’m working on adding a defaultInputValue and some associated changes that will fix this issue.
Added a userQuery arg to onChange which resolves this issue in v0.9.9-0