Skip to content

Commit 03d2670

Browse files
authored
feat(menu): apply strict type for menu type (#28982)
Issue number: N/A --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> `ion-menu` currently accepts any `string` to the `type` property, even though only `overlay`, `push` and `reveal` are only supported. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Adds more explicit types to the `type` property on `ion-menu` ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
1 parent 13b7f8a commit 03d2670

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

core/api.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ ion-menu,prop,maxEdgeStart,number,50,false,false
771771
ion-menu,prop,menuId,string | undefined,undefined,false,true
772772
ion-menu,prop,side,"end" | "start",'start',false,true
773773
ion-menu,prop,swipeGesture,boolean,true,false,false
774-
ion-menu,prop,type,string | undefined,undefined,false,false
774+
ion-menu,prop,type,"overlay" | "push" | "reveal" | undefined,undefined,false,false
775775
ion-menu,method,close,close(animated?: boolean) => Promise<boolean>
776776
ion-menu,method,isActive,isActive() => Promise<boolean>
777777
ion-menu,method,isOpen,isOpen() => Promise<boolean>

core/src/components.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { ScrollBaseDetail, ScrollDetail } from "./components/content/content-int
1818
import { DatetimeChangeEventDetail, DatetimeHighlight, DatetimeHighlightCallback, DatetimeHourCycle, DatetimePresentation, TitleSelectedDatesFormatter } from "./components/datetime/datetime-interface";
1919
import { SpinnerTypes } from "./components/spinner/spinner-configs";
2020
import { InputChangeEventDetail, InputInputEventDetail } from "./components/input/input-interface";
21-
import { MenuChangeEventDetail, Side } from "./components/menu/menu-interface";
21+
import { MenuChangeEventDetail, MenuType, Side } from "./components/menu/menu-interface";
2222
import { ModalBreakpointChangeEventDetail, ModalHandleBehavior } from "./components/modal/modal-interface";
2323
import { NavComponent, NavComponentWithProps, NavOptions, RouterOutletOptions, SwipeGestureHandler, TransitionDoneFn, TransitionInstruction } from "./components/nav/nav-interface";
2424
import { ViewController } from "./components/nav/view-controller";
@@ -53,7 +53,7 @@ export { ScrollBaseDetail, ScrollDetail } from "./components/content/content-int
5353
export { DatetimeChangeEventDetail, DatetimeHighlight, DatetimeHighlightCallback, DatetimeHourCycle, DatetimePresentation, TitleSelectedDatesFormatter } from "./components/datetime/datetime-interface";
5454
export { SpinnerTypes } from "./components/spinner/spinner-configs";
5555
export { InputChangeEventDetail, InputInputEventDetail } from "./components/input/input-interface";
56-
export { MenuChangeEventDetail, Side } from "./components/menu/menu-interface";
56+
export { MenuChangeEventDetail, MenuType, Side } from "./components/menu/menu-interface";
5757
export { ModalBreakpointChangeEventDetail, ModalHandleBehavior } from "./components/modal/modal-interface";
5858
export { NavComponent, NavComponentWithProps, NavOptions, RouterOutletOptions, SwipeGestureHandler, TransitionDoneFn, TransitionInstruction } from "./components/nav/nav-interface";
5959
export { ViewController } from "./components/nav/view-controller";
@@ -1610,7 +1610,7 @@ export namespace Components {
16101610
/**
16111611
* The display type of the menu. Available options: `"overlay"`, `"reveal"`, `"push"`.
16121612
*/
1613-
"type"?: string;
1613+
"type"?: MenuType;
16141614
}
16151615
interface IonMenuButton {
16161616
/**
@@ -6306,7 +6306,7 @@ declare namespace LocalJSX {
63066306
/**
63076307
* The display type of the menu. Available options: `"overlay"`, `"reveal"`, `"push"`.
63086308
*/
6309-
"type"?: string;
6309+
"type"?: MenuType;
63106310
}
63116311
interface IonMenuButton {
63126312
/**

core/src/components/menu/menu-interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,5 @@ export interface MenuCustomEvent<T = any> extends CustomEvent {
5454
detail: T;
5555
target: HTMLIonMenuElement;
5656
}
57+
58+
export type MenuType = 'overlay' | 'reveal' | 'push';

core/src/components/menu/menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { config } from '../../global/config';
1414
import { getIonMode } from '../../global/ionic-global';
1515
import type { Animation, Gesture, GestureDetail } from '../../interface';
1616

17-
import type { MenuChangeEventDetail, MenuI, Side } from './menu-interface';
17+
import type { MenuChangeEventDetail, MenuI, MenuType, Side } from './menu-interface';
1818

1919
const iosEasing = 'cubic-bezier(0.32,0.72,0,1)';
2020
const mdEasing = 'cubic-bezier(0.0,0.0,0.2,1)';
@@ -107,7 +107,7 @@ export class Menu implements ComponentInterface, MenuI {
107107
* The display type of the menu.
108108
* Available options: `"overlay"`, `"reveal"`, `"push"`.
109109
*/
110-
@Prop({ mutable: true }) type?: string;
110+
@Prop({ mutable: true }) type?: MenuType;
111111

112112
@Watch('type')
113113
typeChanged(type: string, oldType: string | undefined) {

0 commit comments

Comments
 (0)