Skip to content

Commit

Permalink
remove webcontent.on new-window
Browse files Browse the repository at this point in the history
  • Loading branch information
koji committed Jan 12, 2024
1 parent acd8450 commit fc16751
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app-shell-odd/src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ export function createUi(dispatch: Dispatch): BrowserWindow {
mainWindow.loadURL(url, { extraHeaders: 'pragma: no-cache\n' })

// open new windows (<a target="_blank" ...) in browser windows
mainWindow.webContents.on('new-window', (event, url) => {
log.debug('Opening external link', { url })
event.preventDefault()
// eslint-disable-next-line @typescript-eslint/no-floating-promises
shell.openExternal(url)
mainWindow.webContents.setWindowOpenHandler(({ url, disposition }) => {
if (disposition === 'new-window' && url === 'about:blank') {
shell.openExternal(url)
return { action: 'deny' }
} else {
return { action: 'allow' }
}
})

return mainWindow
Expand Down

0 comments on commit fc16751

Please sign in to comment.