@@ -8,7 +8,7 @@ import * as DOM from 'vs/base/browser/dom';
8
8
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent' ;
9
9
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent' ;
10
10
import { EventType , Gesture , GestureEvent } from 'vs/base/browser/touch' ;
11
- import { cleanMnemonic , Direction , IMenuOptions , IMenuStyles , Menu , MENU_ESCAPED_MNEMONIC_REGEX , MENU_MNEMONIC_REGEX } from 'vs/base/browser/ui/menu/menu' ;
11
+ import { cleanMnemonic , HorizontalDirection , IMenuDirection , IMenuOptions , IMenuStyles , Menu , MENU_ESCAPED_MNEMONIC_REGEX , MENU_MNEMONIC_REGEX , VerticalDirection } from 'vs/base/browser/ui/menu/menu' ;
12
12
import { ActionRunner , IAction , IActionRunner , Separator , SubmenuAction } from 'vs/base/common/actions' ;
13
13
import { asArray } from 'vs/base/common/arrays' ;
14
14
import { RunOnceScheduler } from 'vs/base/common/async' ;
@@ -32,7 +32,7 @@ export interface IMenuBarOptions {
32
32
visibility ?: string ;
33
33
getKeybinding ?: ( action : IAction ) => ResolvedKeybinding | undefined ;
34
34
alwaysOnMnemonics ?: boolean ;
35
- compactMode ?: Direction ;
35
+ compactMode ?: IMenuDirection ;
36
36
actionRunner ?: IActionRunner ;
37
37
getCompactMenuActions ?: ( ) => IAction [ ] ;
38
38
}
@@ -333,9 +333,9 @@ export class MenuBar extends Disposable {
333
333
} else {
334
334
triggerKeys . push ( KeyCode . Space ) ;
335
335
336
- if ( this . options . compactMode === Direction . Right ) {
336
+ if ( this . options . compactMode ?. horizontal === HorizontalDirection . Right ) {
337
337
triggerKeys . push ( KeyCode . RightArrow ) ;
338
- } else if ( this . options . compactMode === Direction . Left ) {
338
+ } else if ( this . options . compactMode ?. horizontal === HorizontalDirection . Left ) {
339
339
triggerKeys . push ( KeyCode . LeftArrow ) ;
340
340
}
341
341
}
@@ -1007,26 +1007,33 @@ export class MenuBar extends Disposable {
1007
1007
const titleBoundingRect = customMenu . titleElement . getBoundingClientRect ( ) ;
1008
1008
const titleBoundingRectZoom = DOM . getDomNodeZoomLevel ( customMenu . titleElement ) ;
1009
1009
1010
- if ( this . options . compactMode === Direction . Right ) {
1011
- menuHolder . style . top = `${ titleBoundingRect . top } px` ;
1010
+ if ( this . options . compactMode ?. horizontal === HorizontalDirection . Right ) {
1012
1011
menuHolder . style . left = `${ titleBoundingRect . left + this . container . clientWidth } px` ;
1013
- } else if ( this . options . compactMode === Direction . Left ) {
1012
+ } else if ( this . options . compactMode ?. horizontal === HorizontalDirection . Left ) {
1014
1013
menuHolder . style . top = `${ titleBoundingRect . top } px` ;
1015
1014
menuHolder . style . right = `${ this . container . clientWidth } px` ;
1016
1015
menuHolder . style . left = 'auto' ;
1017
1016
} else {
1018
- menuHolder . style . top = `${ titleBoundingRect . bottom * titleBoundingRectZoom } px` ;
1019
1017
menuHolder . style . left = `${ titleBoundingRect . left * titleBoundingRectZoom } px` ;
1020
1018
}
1021
1019
1020
+ if ( this . options . compactMode ?. vertical === VerticalDirection . Above ) {
1021
+ // TODO@benibenj Do not hardcode the height of the menu holder
1022
+ menuHolder . style . top = `${ titleBoundingRect . top - this . menus . length * 30 + this . container . clientHeight } px` ;
1023
+ } else if ( this . options . compactMode ?. vertical === VerticalDirection . Below ) {
1024
+ menuHolder . style . top = `${ titleBoundingRect . top } px` ;
1025
+ } else {
1026
+ menuHolder . style . top = `${ titleBoundingRect . bottom * titleBoundingRectZoom } px` ;
1027
+ }
1028
+
1022
1029
customMenu . buttonElement . appendChild ( menuHolder ) ;
1023
1030
1024
1031
const menuOptions : IMenuOptions = {
1025
1032
getKeyBinding : this . options . getKeybinding ,
1026
1033
actionRunner : this . actionRunner ,
1027
1034
enableMnemonics : this . options . alwaysOnMnemonics || ( this . mnemonicsInUse && this . options . enableMnemonics ) ,
1028
1035
ariaLabel : customMenu . buttonElement . getAttribute ( 'aria-label' ) ?? undefined ,
1029
- expandDirection : this . isCompact ? this . options . compactMode : Direction . Right ,
1036
+ expandDirection : this . isCompact ? this . options . compactMode : { horizontal : HorizontalDirection . Right , vertical : VerticalDirection . Below } ,
1030
1037
useEventAsContext : true
1031
1038
} ;
1032
1039
0 commit comments