|
5 | 5 |
|
6 | 6 | import 'vs/css!./media/activityaction';
|
7 | 7 | import { localize } from 'vs/nls';
|
8 |
| -import { EventType, addDisposableListener, EventHelper } from 'vs/base/browser/dom'; |
| 8 | +import { EventType, addDisposableListener, EventHelper, getDomNodePagePosition } from 'vs/base/browser/dom'; |
9 | 9 | import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
10 | 10 | import { EventType as TouchEventType, GestureEvent } from 'vs/base/browser/touch';
|
11 | 11 | import { Action, IAction, Separator, SubmenuAction, toAction } from 'vs/base/common/actions';
|
@@ -157,23 +157,38 @@ class MenuActivityActionViewItem extends ActivityActionViewItem {
|
157 | 157 | private async showContextMenu(e?: MouseEvent): Promise<void> {
|
158 | 158 | const disposables = new DisposableStore();
|
159 | 159 |
|
160 |
| - let actions: IAction[]; |
161 |
| - if (e?.button !== 2) { |
| 160 | + const isLeftClick = e?.button !== 2; |
| 161 | + |
| 162 | + // Left-click main menu |
| 163 | + if (isLeftClick) { |
162 | 164 | const menu = disposables.add(this.menuService.createMenu(this.menuId, this.contextKeyService));
|
163 |
| - actions = await this.resolveMainMenuActions(menu, disposables); |
164 |
| - } else { |
165 |
| - actions = await this.resolveContextMenuActions(disposables); |
| 165 | + const actions = await this.resolveMainMenuActions(menu, disposables); |
| 166 | + |
| 167 | + this.contextMenuService.showContextMenu({ |
| 168 | + getAnchor: () => this.container, |
| 169 | + anchorAlignment: this.configurationService.getValue('workbench.sideBar.location') === 'left' ? AnchorAlignment.RIGHT : AnchorAlignment.LEFT, |
| 170 | + anchorAxisAlignment: AnchorAxisAlignment.HORIZONTAL, |
| 171 | + getActions: () => actions, |
| 172 | + onHide: () => disposables.dispose() |
| 173 | + }); |
166 | 174 | }
|
167 | 175 |
|
168 |
| - const position = this.configurationService.getValue('workbench.sideBar.location'); |
| 176 | + // Right-click context menu |
| 177 | + else { |
| 178 | + const actions = await this.resolveContextMenuActions(disposables); |
169 | 179 |
|
170 |
| - this.contextMenuService.showContextMenu({ |
171 |
| - getAnchor: () => this.container, |
172 |
| - anchorAlignment: position === 'left' ? AnchorAlignment.RIGHT : AnchorAlignment.LEFT, |
173 |
| - anchorAxisAlignment: AnchorAxisAlignment.HORIZONTAL, |
174 |
| - getActions: () => actions, |
175 |
| - onHide: () => disposables.dispose() |
176 |
| - }); |
| 180 | + const elementPosition = getDomNodePagePosition(this.container); |
| 181 | + const anchor = { |
| 182 | + x: Math.floor(elementPosition.left + (elementPosition.width / 2)), |
| 183 | + y: elementPosition.top + elementPosition.height |
| 184 | + }; |
| 185 | + |
| 186 | + this.contextMenuService.showContextMenu({ |
| 187 | + getAnchor: () => anchor, |
| 188 | + getActions: () => actions, |
| 189 | + onHide: () => disposables.dispose() |
| 190 | + }); |
| 191 | + } |
177 | 192 | }
|
178 | 193 |
|
179 | 194 | protected async resolveMainMenuActions(menu: IMenu, disposables: DisposableStore): Promise<IAction[]> {
|
|
0 commit comments