Skip to content

Commit 8e2790e

Browse files
committed
fixup! fix(cdk-experimental/menu): move shared menu logic to base class
1 parent 2e462b3 commit 8e2790e

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/cdk-experimental/menu/menu-bar.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ import {CdkMenuBase} from './menu-base';
3939
'role': 'menubar',
4040
'class': 'cdk-menu-bar',
4141
'tabindex': '0',
42-
'[attr.aria-orientation]': 'orientation',
43-
'(focus)': 'focusFirstItem()',
4442
'(keydown)': '_handleKeyEvent($event)',
4543
},
4644
providers: [
@@ -50,7 +48,7 @@ import {CdkMenuBase} from './menu-base';
5048
],
5149
})
5250
export class CdkMenuBar extends CdkMenuBase implements AfterContentInit, OnDestroy {
53-
override orientation: 'horizontal' | 'vertical' = 'horizontal';
51+
override readonly orientation: 'horizontal' | 'vertical' = 'horizontal';
5452

5553
override menuStack: MenuStack;
5654

src/cdk-experimental/menu/menu-base.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ import {MENU_STACK, MenuStack, MenuStackItem} from './menu-stack';
2727
import {Menu} from './menu-interface';
2828
import {PointerFocusTracker} from './pointer-focus-tracker';
2929

30-
@Directive()
30+
@Directive({
31+
host: {
32+
'[attr.aria-orientation]': 'orientation',
33+
'(focus)': 'focusFirstItem()',
34+
},
35+
})
3136
export abstract class CdkMenuBase
3237
extends CdkMenuGroup
3338
implements Menu, AfterContentInit, OnDestroy
@@ -36,7 +41,7 @@ export abstract class CdkMenuBase
3641
* Sets the aria-orientation attribute and determines where menus will be opened.
3742
* Does not affect styling/layout.
3843
*/
39-
@Input('cdkMenuOrientation') orientation: 'horizontal' | 'vertical' = 'vertical';
44+
readonly orientation: 'horizontal' | 'vertical' = 'vertical';
4045

4146
/** All child MenuItem elements nested in this Menu. */
4247
@ContentChildren(CdkMenuItem, {descendants: true})

src/cdk-experimental/menu/menu-interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface Menu extends MenuStackItem {
1919
_elementRef: ElementRef<HTMLElement>;
2020

2121
/** The orientation of the menu */
22-
orientation: 'horizontal' | 'vertical';
22+
readonly orientation: 'horizontal' | 'vertical';
2323

2424
/** Place focus on the first MenuItem in the menu. */
2525
focusFirstItem(focusOrigin: FocusOrigin): void;

src/cdk-experimental/menu/menu.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@ import {CdkMenuBase} from './menu-base';
5050
selector: '[cdkMenu]',
5151
exportAs: 'cdkMenu',
5252
host: {
53-
'[tabindex]': '_isInline() ? 0 : null',
5453
'role': 'menu',
5554
'class': 'cdk-menu',
55+
'[tabindex]': '_isInline() ? 0 : null',
5656
'[class.cdk-menu-inline]': '_isInline()',
57-
'[attr.aria-orientation]': 'orientation',
58-
'(focus)': 'focusFirstItem()',
5957
'(keydown)': '_handleKeyEvent($event)',
6058
},
6159
providers: [

0 commit comments

Comments
 (0)