Move ctrlBindings
check into keyboardBindings
function body to avoid global navigator
reference
#53
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.
The reference to
navigator
at the top level makescombobox-nav
unusable with SSR processes like React SSR. In particular, I am working on a component in PRC and cannot render the docs ifcombobox-nav
is a dependency. For details, see the first list item in Gatsby's Debugging HTML Builds:When using this utility with React, it makes complete sense to construct the class inside a
useEffect
hook, so that part is already taken care of. However, because the reference tonavigator
is global, that doesn't fix the error.We can easily fix this by just moving the
navigator
reference so it doesn't get called until (at minimum) the class gets constructed, so that's what I've done with this PR.I considered putting the check inside the
keyboardBindings
function, but the performance impact of an additional regex check on every keyboard event felt unnecessarym, so I moved it into the class constructor and passed it as a parameter tokeyboardBindings
instead.