-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(item-sliding): swiping inside of virtual scroller now prevents sc…
…rolling (#25345)
- Loading branch information
1 parent
d5cde5e
commit 5a1a5f6
Showing
5 changed files
with
175 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
core/src/components/item-sliding/test/basic/item-sliding.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '@utils/test/playwright'; | ||
|
||
test.describe('item-sliding: basic', () => { | ||
test('should not scroll when the item-sliding is swiped', async ({ page, browserName }, testInfo) => { | ||
test.skip(browserName === 'webkit', 'mouse.wheel is not available in WebKit'); | ||
test.skip(testInfo.project.metadata.rtl === true, 'This feature does not have RTL-specific behaviors'); | ||
|
||
await page.goto(`/src/components/item-sliding/test/basic`); | ||
|
||
const itemSlidingEl = page.locator('#two-options'); | ||
const scrollEl = page.locator('ion-content .inner-scroll'); | ||
|
||
expect(await scrollEl.evaluate((el: HTMLElement) => el.scrollTop)).toEqual(0); | ||
|
||
const box = (await itemSlidingEl.boundingBox())!; | ||
const centerX = box.x + box.width / 2; | ||
const centerY = box.y + box.height / 2; | ||
|
||
await page.mouse.move(centerX, centerY); | ||
await page.mouse.down(); | ||
await page.mouse.move(centerX - 30, centerY); | ||
|
||
/** | ||
* Do not use scrollToBottom() or other scrolling methods | ||
* on ion-content as those will update the scroll position. | ||
* Setting scrollTop still works even with overflow-y: hidden. | ||
* However, simulating a user gesture should not scroll the content. | ||
*/ | ||
await page.mouse.wheel(0, 100); | ||
await page.waitForChanges(); | ||
|
||
expect(await scrollEl.evaluate((el: HTMLElement) => el.scrollTop)).toEqual(0); | ||
}); | ||
}); |
89 changes: 89 additions & 0 deletions
89
core/src/components/item-sliding/test/scroll-target/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Item Sliding - Scroll Target</title> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" | ||
/> | ||
<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> | ||
<style> | ||
.ion-content-scroll-host { | ||
width: 100%; | ||
height: 100%; | ||
|
||
overflow-y: scroll; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<ion-app> | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title>Item Sliding - Scroll Target</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content class="ion-padding" scroll-y="false"> | ||
<div class="ion-content-scroll-host"> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur faucibus nulla a nunc tincidunt semper. | ||
Nam nibh lorem, pharetra ac ex ac, tempus fringilla est. Aenean tincidunt ipsum pellentesque, consequat | ||
libero id, feugiat leo. In vestibulum faucibus velit, non tincidunt erat tincidunt in. Donec a diam sed nisl | ||
convallis maximus. Aenean cursus sagittis lorem vitae tristique. Pellentesque pellentesque, quam eget | ||
lobortis finibus, lectus lorem maximus purus, quis sagittis tortor sem sed tellus. | ||
</p> | ||
|
||
<ion-item-sliding> | ||
<ion-item> | ||
<ion-label>Item Sliding</ion-label> | ||
</ion-item> | ||
<ion-item-options side="end" class="show-options"> | ||
<ion-item-option color="primary"> | ||
<ion-icon slot="start" ios="ellipsis-horizontal" md="ellipsis-vertical"></ion-icon> | ||
<span class="more-text"></span> | ||
</ion-item-option> | ||
</ion-item-options> | ||
</ion-item-sliding> | ||
|
||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur faucibus nulla a nunc tincidunt semper. | ||
Nam nibh lorem, pharetra ac ex ac, tempus fringilla est. Aenean tincidunt ipsum pellentesque, consequat | ||
libero id, feugiat leo. In vestibulum faucibus velit, non tincidunt erat tincidunt in. Donec a diam sed nisl | ||
convallis maximus. Aenean cursus sagittis lorem vitae tristique. Pellentesque pellentesque, quam eget | ||
lobortis finibus, lectus lorem maximus purus, quis sagittis tortor sem sed tellus. | ||
</p> | ||
|
||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur faucibus nulla a nunc tincidunt semper. | ||
Nam nibh lorem, pharetra ac ex ac, tempus fringilla est. Aenean tincidunt ipsum pellentesque, consequat | ||
libero id, feugiat leo. In vestibulum faucibus velit, non tincidunt erat tincidunt in. Donec a diam sed nisl | ||
convallis maximus. Aenean cursus sagittis lorem vitae tristique. Pellentesque pellentesque, quam eget | ||
lobortis finibus, lectus lorem maximus purus, quis sagittis tortor sem sed tellus. | ||
</p> | ||
|
||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur faucibus nulla a nunc tincidunt semper. | ||
Nam nibh lorem, pharetra ac ex ac, tempus fringilla est. Aenean tincidunt ipsum pellentesque, consequat | ||
libero id, feugiat leo. In vestibulum faucibus velit, non tincidunt erat tincidunt in. Donec a diam sed nisl | ||
convallis maximus. Aenean cursus sagittis lorem vitae tristique. Pellentesque pellentesque, quam eget | ||
lobortis finibus, lectus lorem maximus purus, quis sagittis tortor sem sed tellus. | ||
</p> | ||
|
||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur faucibus nulla a nunc tincidunt semper. | ||
Nam nibh lorem, pharetra ac ex ac, tempus fringilla est. Aenean tincidunt ipsum pellentesque, consequat | ||
libero id, feugiat leo. In vestibulum faucibus velit, non tincidunt erat tincidunt in. Donec a diam sed nisl | ||
convallis maximus. Aenean cursus sagittis lorem vitae tristique. Pellentesque pellentesque, quam eget | ||
lobortis finibus, lectus lorem maximus purus, quis sagittis tortor sem sed tellus. | ||
</p> | ||
</div> | ||
</ion-content> | ||
</ion-app> | ||
</body> | ||
</html> |
38 changes: 38 additions & 0 deletions
38
core/src/components/item-sliding/test/scroll-target/item-sliding.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '@utils/test/playwright'; | ||
|
||
test.describe('item-sliding: scroll-target', () => { | ||
test('should not scroll when the item-sliding is swiped in custom scroll target', async ({ | ||
page, | ||
browserName, | ||
}, testInfo) => { | ||
test.skip(browserName === 'webkit', 'mouse.wheel is not available in WebKit'); | ||
test.skip(testInfo.project.metadata.rtl === true, 'This feature does not have RTL-specific behaviors'); | ||
|
||
await page.goto(`/src/components/item-sliding/test/scroll-target`); | ||
|
||
const itemSlidingEl = page.locator('ion-item-sliding'); | ||
const scrollEl = page.locator('.ion-content-scroll-host'); | ||
|
||
expect(await scrollEl.evaluate((el: HTMLElement) => el.scrollTop)).toEqual(0); | ||
|
||
const box = (await itemSlidingEl.boundingBox())!; | ||
const centerX = box.x + box.width / 2; | ||
const centerY = box.y + box.height / 2; | ||
|
||
await page.mouse.move(centerX, centerY); | ||
await page.mouse.down(); | ||
await page.mouse.move(centerX - 30, centerY); | ||
|
||
/** | ||
* Do not use scrollToBottom() or other scrolling methods | ||
* on ion-content as those will update the scroll position. | ||
* Setting scrollTop still works even with overflow-y: hidden. | ||
* However, simulating a user gesture should not scroll the content. | ||
*/ | ||
await page.mouse.wheel(0, 100); | ||
await page.waitForChanges(); | ||
|
||
expect(await scrollEl.evaluate((el: HTMLElement) => el.scrollTop)).toEqual(0); | ||
}); | ||
}); |