-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Core: Do no expand the widgets on the side-bars for the context menu
Before, right clicking on different menus would focus the menu item and open it, however this should not be the case. There was a dangling code in the handleContextMenu which causes this effect, as it was checking for the id when right clicked and looked up the ID for the menu-item and set the current title to the menu-item. Issue ID: 4367 Signed-off-by: Muhammad Anas Shahid <muhammad.shahid@ericsson.com>
- Loading branch information
Muhammad Anas Shahid
committed
Mar 23, 2020
1 parent
868061f
commit d478265
Showing
7 changed files
with
188 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2019 TypeFox and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { TabBar, Widget, Title } from '@phosphor/widgets'; | ||
import { injectable, inject } from 'inversify'; | ||
import { ApplicationShell } from './shell/application-shell'; | ||
|
||
@injectable() | ||
export class ContextMenuService { | ||
|
||
constructor( | ||
@inject(ApplicationShell) protected readonly shell: ApplicationShell | ||
) { } | ||
|
||
findTitle(tabBar: TabBar<Widget> | undefined, event?: Event): Title<Widget> | undefined { | ||
if (event && event.target) { | ||
let tabNode: HTMLElement | null = event.target as HTMLElement; | ||
while (tabNode && !tabNode.classList.contains('p-TabBar-tab')) { | ||
tabNode = tabNode.parentElement; | ||
} | ||
if (tabBar && tabNode && tabNode.title) { | ||
let title = tabBar.titles.find(t => t.caption === tabNode!.title); | ||
if (title) { | ||
return title; | ||
} | ||
title = tabBar.titles.find(t => t.label === tabNode!.title); | ||
if (title) { | ||
return title; | ||
} | ||
} | ||
} | ||
return tabBar ? tabBar.currentTitle || undefined : undefined; | ||
} | ||
|
||
findTabBar(event?: Event): TabBar<Widget> | undefined { | ||
if (event && event.target) { | ||
const tabBar = this.shell.findWidgetForElement(event.target as HTMLElement); | ||
if (tabBar instanceof TabBar) { | ||
return tabBar; | ||
} | ||
} | ||
return this.shell.currentTabBar; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.