Option to restore the last search when KBar re-opens
aghster opened this issue · 1 comments
Currently, when KBar is re-opened after KBar was opened, a search string was entered into the input field and then KBar was closed again, the input field is empty. Depending on the use case it could be better if afer re-opening KBar the input field still contained the previously entered search string — ideally with this search string being selected so that one can quickly replace it to start a new search.
To implement this, I tried to store the current search string when KBar gets closed and then prefill the input field with the stored search string when KBar is re-opened. However, as it seems, this is not possible, since the search string is forcefully reset whenever KBar is opened:
Lines 31 to 35 in 30657cd
However, if I replace this by
React.useEffect(() => {
query.getInput().select();
}, [currentRootActionId, query]);
I get exactly, what I tried to achieve. Though, I would prefer not to have to modify the original code.
Would it be possible to add an option to KBar so one can easily choose between the current and the suggested mode of operation? Unfortunately, I am not very familiar with React so that I cannot provide a PR myself.
Hey! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.