-
Notifications
You must be signed in to change notification settings - Fork 13.5k
fix(menu) menus on the same side are not automatically disabled #28269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f3f93da
9cf14bf
ba31223
cb42554
c9669de
5570448
90425eb
5a8d5dc
0787dc8
01f4a27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Menu - Multiple</title> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" | ||
/> | ||
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" /> | ||
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" /> | ||
<script src="../../../../../scripts/testing/scripts.js"></script> | ||
<script nomodule src="../../../../../dist/ionic/ionic.js"></script> | ||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script> | ||
<script type="module"> | ||
import { menuController } from '../../../../dist/ionic/index.esm.js'; | ||
window.menuController = menuController; | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
<ion-menu side="start" menu-id="primary-menu" id="primary-menu" content-id="main"> | ||
<ion-header> | ||
<ion-toolbar color="primary"> | ||
<ion-title>Primary</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content class="ion-padding"> Menu Content </ion-content> | ||
</ion-menu> | ||
|
||
<ion-menu side="start" menu-id="secondary-menu" id="secondary-menu" content-id="main"> | ||
<ion-header> | ||
<ion-toolbar color="secondary"> | ||
<ion-title>Secondary</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content class="ion-padding"> Menu Content </ion-content> | ||
</ion-menu> | ||
|
||
<ion-menu disabled="true" side="end" menu-id="success-menu" id="success-menu" content-id="main"> | ||
<ion-header> | ||
<ion-toolbar color="success"> | ||
<ion-title>Success</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content class="ion-padding"> Menu Content </ion-content> | ||
</ion-menu> | ||
|
||
<ion-menu disabled="true" side="end" menu-id="danger-menu" id="danger-menu" content-id="main"> | ||
<ion-header> | ||
<ion-toolbar color="danger"> | ||
<ion-title>Danger</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content class="ion-padding"> Menu Content </ion-content> | ||
</ion-menu> | ||
|
||
<div class="ion-page" id="main"> | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-buttons slot="start"> | ||
<ion-menu-button menu="primary-menu" color="primary"></ion-menu-button> | ||
<ion-menu-button menu="secondary-menu" color="secondary"></ion-menu-button> | ||
</ion-buttons> | ||
<ion-title>Menu - Multiple</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content class="ion-padding">Content</ion-content> | ||
</div> | ||
</ion-app> | ||
</body> | ||
<scrip | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { expect } from '@playwright/test'; | ||
import { configs, test } from '@utils/test/playwright'; | ||
|
||
/** | ||
* This behavior does not vary across modes/directions | ||
*/ | ||
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => { | ||
test.describe(title('menu: multiple'), () => { | ||
test.beforeEach(async ({ page }, testInfo) => { | ||
testInfo.annotations.push({ | ||
type: 'issue', | ||
description: 'https://github.com/ionic-team/ionic-framework/issues/18974', | ||
}); | ||
|
||
await page.goto(`/src/components/menu/test/multiple`, config); | ||
}); | ||
|
||
test('should present each menu on the same side individually', async ({ page }) => { | ||
const primaryMenu = page.locator('ion-menu#primary-menu'); | ||
const secondaryMenu = page.locator('ion-menu#secondary-menu'); | ||
|
||
await primaryMenu.evaluate((el: HTMLIonMenuElement) => el.open()); | ||
await expect(primaryMenu).toBeVisible(); | ||
|
||
await primaryMenu.evaluate((el: HTMLIonMenuElement) => el.close()); | ||
await expect(primaryMenu).toBeHidden(); | ||
|
||
await secondaryMenu.evaluate((el: HTMLIonMenuElement) => el.open()); | ||
await expect(secondaryMenu).toBeVisible(); | ||
|
||
await secondaryMenu.evaluate((el: HTMLIonMenuElement) => el.close()); | ||
await expect(secondaryMenu).toBeHidden(); | ||
}); | ||
|
||
test('should close first menu when showing another menu on same side', async ({ page }) => { | ||
const primaryMenu = page.locator('ion-menu#primary-menu'); | ||
const secondaryMenu = page.locator('ion-menu#secondary-menu'); | ||
|
||
await primaryMenu.evaluate((el: HTMLIonMenuElement) => el.open()); | ||
await expect(primaryMenu).toBeVisible(); | ||
|
||
await secondaryMenu.evaluate((el: HTMLIonMenuElement) => el.open()); | ||
await expect(primaryMenu).toBeHidden(); | ||
await expect(secondaryMenu).toBeVisible(); | ||
}); | ||
|
||
test('passing side to the menuController when multiple menus have that side should result in a warning', async ({ | ||
page, | ||
}) => { | ||
const logs: string[] = []; | ||
|
||
page.on('console', (msg) => { | ||
if (msg.type() === 'warning') { | ||
logs.push(msg.text()); | ||
} | ||
}); | ||
|
||
await page.evaluate(() => (window as any).menuController.open('start')); | ||
|
||
expect(logs.length).toBe(1); | ||
}); | ||
|
||
test('passing side to the menuController when multiple disabled menus have that side should result in a warning', async ({ | ||
page, | ||
}) => { | ||
const logs: string[] = []; | ||
|
||
page.on('console', (msg) => { | ||
if (msg.type() === 'warning') { | ||
logs.push(msg.text()); | ||
} | ||
}); | ||
|
||
await page.evaluate(() => (window as any).menuController.open('end')); | ||
|
||
expect(logs.length).toBe(1); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have the work tracked to update the docs in light of this change, particularly the Multiple Menus section? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the reminder! I meant to do this as part of my work, but I forgot. Here's the PR: ionic-team/ionic-docs#3186 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please include an annotation for the issue. Not sure if it can go on the
describe
level or it should be inside thebeforeEach
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reminder! Added in 5570448 and 90425eb