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: Correct modal focus behavior on macOS #19061

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions atom/browser/ui/cocoa/atom_ns_window_delegate.mm
Expand Up @@ -83,11 +83,11 @@ - (NSRect)windowWillUseStandardFrame:(NSWindow*)window
return frame;
}

- (void)windowDidBecomeMain:(NSNotification*)notification {
- (void)windowDidBecomeKey:(NSNotification*)notification {
shell_->NotifyWindowFocus();
}

- (void)windowDidResignMain:(NSNotification*)notification {
- (void)windowDidResignKey:(NSNotification*)notification {
shell_->NotifyWindowBlur();
}

Expand Down
27 changes: 27 additions & 0 deletions spec/api-browser-window-spec.js
Expand Up @@ -2330,6 +2330,33 @@ describe('BrowserWindow module', () => {
})
})

describe('focus event', () => {
it('should not emit if focusing on a main window with a modal open', (done) => {
const child = new BrowserWindow({
parent: w,
modal: true,
show: false
})

child.once('ready-to-show', () => {
child.show()
})

child.on('show', () => {
w.once('focus', () => {
expect(child.isDestroyed()).to.equal(true)
done()
})
w.focus() // this should not trigger the above listener
child.close()
})

// act
child.loadURL(server.url)
w.show()
})
})

describe('sheet-begin event', () => {
let sheet = null

Expand Down