Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix #150: Reset global handler resolution state when a new GlobalHo… #178

Merged
merged 2 commits into from
May 18, 2019

Conversation

greena13
Copy link
Owner

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 of GlobalHotKeys 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.

@@ -73,6 +73,8 @@ class GlobalKeyEventStrategy extends AbstractKeyEventStrategy {

this._updateDocumentHandlers();

this._initHandlerResolutionState();
Copy link
Owner Author

@greena13 greena13 May 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅⚔️Check the behaviour of this._updateDocumentHandlers() to make sure calling these methods in this sequence will always work as intended.

Copy link
Owner Author

@greena13 greena13 May 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 🚀See if there is a way of wrapping the resetting of state in this._initHandlerResolutionState() in a condition that will abort resetting the state if it's apparent handler resolution hasn't actually taken place yet, and the state is already set to the default values.

@greena13 greena13 merged commit 7d5b752 into master May 18, 2019
@greena13 greena13 deleted the bugfix_150 branch May 18, 2019 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant