Skip to content

Commit

Permalink
Close menu dropdown when a quick palette is opened
Browse files Browse the repository at this point in the history
Fixes: #6847

Signed-off-by: Gareth Whittaker <[email protected]>
  • Loading branch information
garethwhittaker authored and akosyakov committed Feb 20, 2020
1 parent f114ded commit 31dbbc1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## v0.16.0

- [monaco] close an active menubar dropdown when the quick palette is launched [#7136](https://github.com/eclipse-theia/theia/pull/7136)
- [core] added a new React-based dialog type `ReactDialog` [#6855](https://github.com/eclipse-theia/theia/pull/6855)
- [repo] added 2 new npm scripts:
- `test:references`: fails if typescript references are out of sync.
Expand Down
17 changes: 16 additions & 1 deletion packages/monaco/src/browser/monaco-quick-open-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/

import { injectable, inject, postConstruct } from 'inversify';
import { injectable, inject, optional, postConstruct } from 'inversify';
import { MessageType } from '@theia/core/lib/common/message-service-protocol';
import {
QuickOpenService, QuickOpenOptions, QuickOpenItem, QuickOpenGroupItem,
Expand All @@ -25,6 +25,7 @@ import { ContextKey } from '@theia/core/lib/browser/context-key-service';
import { MonacoContextKeyService } from './monaco-context-key-service';
import { QuickOpenHideReason } from '@theia/core/lib/common/quick-open-service';
import { MonacoResolvedKeybinding } from './monaco-resolved-keybinding';
import { BrowserMenuBarContribution } from '@theia/core/lib/browser/menu/browser-menu-plugin';

export interface MonacoQuickOpenControllerOpts extends monaco.quickOpen.IQuickOpenControllerOpts {
valueSelection?: Readonly<[number, number]>;
Expand All @@ -51,6 +52,9 @@ export class MonacoQuickOpenService extends QuickOpenService {
@inject(KeybindingRegistry)
protected readonly keybindingRegistry: KeybindingRegistry;

@inject(BrowserMenuBarContribution) @optional()
protected readonly browserMenuBarContribution?: BrowserMenuBarContribution;

protected inQuickOpenKey: ContextKey<boolean>;

constructor() {
Expand Down Expand Up @@ -113,6 +117,17 @@ export class MonacoQuickOpenService extends QuickOpenService {
}

internalOpen(opts: MonacoQuickOpenControllerOpts): void {
const browserMenuBarContribution = this.browserMenuBarContribution;
if (browserMenuBarContribution) {
const browserMenuBar = browserMenuBarContribution.menuBar;
if (browserMenuBar) {
const activeMenu = browserMenuBar.activeMenu;
if (activeMenu) {
activeMenu.close();
}
}
}

// eslint-disable-next-line no-null/no-null
if (this.widgetNode && this.widgetNode.offsetParent !== null) {
this.hide();
Expand Down

0 comments on commit 31dbbc1

Please sign in to comment.