Bug: don't invoke this.focusInput in mousetrap callback #1157
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When calling this.focusInput() in the moustrap callback it is possible for this.commandPaletteInput.input (as used in this.focusInput()) to be null since this.commandPaletteInput is set during the render which is not guaranteed to happen first. This creates a race condition that can lead to an error being logged on the console in some cases.
this.focusInput() is still called by afterOpenModal and thus the desired effect is preserved.
I have published a package published that just bumps to react 18 and fixes this bug if you want to test out the changes really quickly. https://www.npmjs.com/package/react18-react-command-palette
Thank you for the awesome package. It saved me a ton of time and allowed me to put together a what would otherwise be complicated feature with extreme ease!