🐛 Fix #150: Reset global handler resolution state when a new GlobalHo… #178
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.
Context
#150 documents that when a
GlobalHotKeys
component is mounted, unmounted and then re-mounted, it does not reset the handler resolution state on the second mount (even though the configuration ofGlobalHotKeys
that it should be using to resolve the handlers has changed).This issue would likely also arise in a number of other situations where
GlobalHotKeys
components were being unmounted and remounted or updated - but the situation above is probably the simplest case.Thanks to the investigation of @StephenHaney and the pull request of @mrlubos (#157) the solution of resetting the handle resolution state every time a new
GlobalHotKeys
component mounted, presented itself.This pull request
Simply adds the change suggested above, and resets the handler resolution state whenever a new
GlobalHotKeys
component mounts.This is a relatively light-weight operation, as when multiple
GlobalHotKeys
components are mounting (and the user is not yet pressing any keys) we are effectively clearing empty objects, anyway.A test has been added that correctly reported the failure condition, and is now passing.