fix: Correct modal focus behavior on macOS#18995
Merged
codebytere merged 8 commits intomasterfrom Jul 1, 2019
Merged
Conversation
jkleinsc
requested changes
Jun 26, 2019
Member
jkleinsc
left a comment
There was a problem hiding this comment.
Nice work @erickzhao! Overall looks good to me - I would just make your new test a little more robust by verifying the main window can regain focus once the modal is closed.
Member
Author
|
@jkleinsc Seems like calling |
codebytere
approved these changes
Jun 28, 2019
jkleinsc
approved these changes
Jul 1, 2019
|
Release Notes Persisted
|
This was referenced Jul 1, 2019
Contributor
|
I have automatically backported this PR to "4-2-x", please check out #19061 |
Contributor
|
I have automatically backported this PR to "6-0-x", please check out #19062 |
Contributor
|
I have automatically backported this PR to "5-0-x", please check out #19063 |
3 tasks
This was referenced Jul 6, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of Change
Fixes #18502
This PR changes the
focusandblurevents that we emit in Electron to listen to changes in key window rather than main window. It swaps outwindowDidBecomeMainandwindowDidResignMainforwindowDidBecomeKeyandwindowDidResignKey, respectively.It seems to work as intended now. Also added a new test to test this exact situation. Please let me know if there's a less convoluted way to test this specific case, since it seems like I'm listening to a very specific series of events. Test seems to be working locally on my end, and fails on a downloaded CI build from
master. ✅Context
In our macOS code, the
NativeWindowMac::Show()function innative_window_mac.mmcalls thisbeginSheetfunction, which specifies that:For additional context, see Apple developer documentation on key and main windows here.
Fiddle: https://gist.github.com/c9c19684f6e0d23c102161fb3e86500b
cc @codebytere @deermichel
Checklist
npm testpassesRelease Notes
Notes: Fixed bug on macOS where the main window could be targeted for a
focusevent when it was disabled behind a modal.