-
Type: Task
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
None
-
3
-
Not Needed
Currently in Compass we handle links in two main ways:
1. If the link has `_blank` on it then when it is clicked it is handled by the `new-window` event in electron:
https://github.com/mongodb-js/compass/blob/main/packages/compass/src/main/window-manager.ts#L139
2. If the link doesn't have `_blank` on it then we currently do not handle the link handling unless the target of the event is an `a` element. This isn't always the case with links without `_blank` as there might be a `span` or something inside of the `a` tag which means this check isn't very robust. The check happens here in the `onLinkClick` function:
https://github.com/mongodb-js/compass/blob/main/packages/compass/src/app/index.js#L263
In this ticket let's add another handler for the `will-navigate` web contents event to handle links that are clicked without `_blank`. Let's remove the handling that has the not fully covering `a` tag check as well (and keep the `new-window` handler) since it will no longer need to be used.
Something like:
window.webContents.on('will-navigate', function (event, url)
);
`will-navigate` docs: https://www.electronjs.org/docs/latest/api/web-contents#event-will-navigate
- is related to
-
COMPASS-6145 Clicking the information icon opens documentation site with no way back
- Closed
- related to
-
COMPASS-5187 Refactor deprecated on('new-window') usage to setWindowOpenHandler and use a tags with href instead of remote.shell.openExternal in Compass plugins
- Closed