mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Open treeview links in a new tab with a right click on a node.
This commit is contained in:
parent
145aca485c
commit
c5a6bbc749
1 changed files with 13 additions and 0 deletions
|
@ -84,11 +84,24 @@ export default class extends Controller {
|
|||
}, [BS5Theme, FAIconTheme]);
|
||||
|
||||
this.treeTarget.addEventListener(EVENT_INITIALIZED, (event) => {
|
||||
/** @type {BSTreeView} */
|
||||
const treeView = event.detail.treeView;
|
||||
treeView.revealNode(treeView.getSelected());
|
||||
|
||||
//Add contextmenu event listener to the tree, which allows us to open the links in a new tab with a right click
|
||||
treeView.getTreeElement().addEventListener("contextmenu", this._onContextMenu.bind(this));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
_onContextMenu(event)
|
||||
{
|
||||
//Find the node that was clicked and open link in new tab
|
||||
const node = this._tree._domToNode(event.target);
|
||||
if(node && node.href) {
|
||||
event.preventDefault();
|
||||
window.open(node.href, '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
collapseAll() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue