Skip to content

Commit 36fac7b

Browse files
authored
fix: call SetCanActivate in setFocusable (electron#21846)
1 parent 100a85f commit 36fac7b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

shell/browser/native_window_views.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,7 @@ void NativeWindowViews::SetContentProtection(bool enable) {
992992
}
993993

994994
void NativeWindowViews::SetFocusable(bool focusable) {
995+
widget()->widget_delegate()->SetCanActivate(focusable);
995996
#if defined(OS_WIN)
996997
LONG ex_style = ::GetWindowLong(GetAcceleratedWidget(), GWL_EXSTYLE);
997998
if (focusable)

spec-main/api-browser-window-spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,17 @@ describe('BrowserWindow module', () => {
687687
await closeWindow(w2, { assertNotWindows: false })
688688
})
689689
})
690+
691+
describe('BrowserWindow.setFocusable()', () => {
692+
it('can set unfocusable window to focusable', async () => {
693+
const w2 = new BrowserWindow({ focusable: false })
694+
const w2Focused = emittedOnce(w2, 'focus')
695+
w2.setFocusable(true)
696+
w2.focus()
697+
await w2Focused
698+
await closeWindow(w2, { assertNotWindows: false })
699+
})
700+
})
690701
})
691702

692703
describe('sizing', () => {

0 commit comments

Comments
 (0)