Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions core/src/components/menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@


.menu-inner {
@include position(0, auto, 0, 0);
@include transform(translateX(-9999px));

display: flex;
Expand All @@ -62,21 +61,13 @@
:host(.menu-side-start) .menu-inner {
--ion-safe-area-right: 0px;

@include multi-dir() {
/* stylelint-disable property-disallowed-list */
right: auto;
left: 0;
}
@include position(0, auto, 0, 0);
}

:host(.menu-side-end) .menu-inner {
--ion-safe-area-left: 0px;

@include multi-dir() {
right: 0;
left: auto;
/* stylelint-enable property-disallowed-list */
}
@include position(0, 0, 0, auto);
}

ion-backdrop {
Expand Down
18 changes: 14 additions & 4 deletions core/src/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ export class Menu implements ComponentInterface, MenuI {
@Watch('side')
protected sideChanged() {
this.isEndSide = isEnd(this.side);
/**
* Menu direction animation is calculated based on the document direction.
* If the document direction changes, we need to create a new animation.
*/
this.animation = undefined;
}

/**
Expand Down Expand Up @@ -413,10 +418,16 @@ export class Menu implements ComponentInterface, MenuI {
// Menu swipe animation takes the menu's inner width as parameter,
// If `offsetWidth` changes, we need to create a new animation.
const width = this.menuInnerEl!.offsetWidth;
if (width === this.width && this.animation !== undefined) {
/**
* Menu direction animation is calculated based on the document direction.
* If the document direction changes, we need to create a new animation.
*/
const isEndSide = isEnd(this.side);
if (width === this.width && this.animation !== undefined && isEndSide === this.isEndSide) {
return;
}
this.width = width;
this.isEndSide = isEndSide;

// Destroy existing animation
if (this.animation) {
Expand Down Expand Up @@ -703,7 +714,7 @@ export class Menu implements ComponentInterface, MenuI {
}

render() {
const { isEndSide, type, disabled, isPaneVisible, inheritedAttributes } = this;
const { type, disabled, isPaneVisible, inheritedAttributes, side } = this;
const mode = getIonMode(this);

return (
Expand All @@ -714,8 +725,7 @@ export class Menu implements ComponentInterface, MenuI {
[mode]: true,
[`menu-type-${type}`]: true,
'menu-enabled': !disabled,
'menu-side-end': isEndSide,
'menu-side-start': !isEndSide,
[`menu-side-${side}`]: true,
'menu-pane-visible': isPaneVisible,
}}
>
Expand Down
51 changes: 51 additions & 0 deletions core/src/components/menu/test/basic/menu.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,57 @@ test.describe('menu: basic', () => {

await expect(scrollTop).toBe(200);
});

test('should render on the correct side when side is changed dynamically', async ({ page, skip }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/25601',
});

skip.mode('ios', 'Dynamic side changes are not mode dependent');

const ionDidOpen = await page.spyOnEvent('ionDidOpen');
const ionDidClose = await page.spyOnEvent('ionDidClose');

await page.locator('[menu-id="start-menu"]').evaluate(async (el: HTMLIonMenuElement) => {
el.side = 'end';
});
await page.click('#open-start');
await ionDidOpen.next();

await expect(page).toHaveScreenshot(`menu-basic-side-toggled-${page.getSnapshotSettings()}.png`);

await page.locator('[menu-id="start-menu"]').evaluate(async (el: HTMLIonMenuElement) => {
await el.close();
});
await ionDidClose.next();
});

test('should render on the correct side when document direction is changed dynamically', async ({ page, skip }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/25601',
});

skip.rtl('Document direction is not dependent on initial load');
skip.mode('ios', 'Dynamic side changes are not mode dependent');

const ionDidOpen = await page.spyOnEvent('ionDidOpen');
const ionDidClose = await page.spyOnEvent('ionDidClose');

await page.evaluate(() => {
document.dir = 'rtl';
});
await page.click('#open-start');
await ionDidOpen.next();

await expect(page).toHaveScreenshot(`menu-basic-doc-dir-toggled-${page.getSnapshotSettings()}.png`);

await page.locator('[menu-id="start-menu"]').evaluate(async (el: HTMLIonMenuElement) => {
await el.close();
});
await ionDidClose.next();
});
});

async function testMenu(page: E2EPage, menu: Locator, menuId: string) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.