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
11 changes: 10 additions & 1 deletion core/src/components/item-sliding/item-sliding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,16 @@ export class ItemSliding implements ComponentInterface {
*/
@Method()
async open(side: Side | undefined) {
if (this.item === null) {
/**
* It is possible for the item to be added to the DOM
* after the item-sliding component was created. As a result,
* if this.item is null, then we should attempt to
* query for the ion-item again.
* However, if the item is already defined then
* we do not query for it again.
*/
const item = (this.item = this.item ?? this.el.querySelector('ion-item'));
if (item === null) {
return;
}

Expand Down
49 changes: 49 additions & 0 deletions core/src/components/item-sliding/test/async/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>Item Sliding - Async</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>
</head>

<body>
<ion-app>
<ion-header>
<ion-toolbar>
<ion-title>Item Sliding - Basic</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<ion-list>
<ion-item-sliding>
<ion-item-options side="end">
<ion-item-option>Option</ion-item-option>
</ion-item-options>
</ion-item-sliding>
</ion-list>

<script>
const itemSliding = document.querySelector('ion-item-sliding');
setTimeout(() => {
const item = document.createElement('ion-item');
item.innerText = 'Item Sliding Option';
itemSliding.appendChild(item);

item.onclick = () => {
itemSliding.open('end');
};
}, 250);
</script>
</ion-content>
</ion-app>
</body>
</html>
23 changes: 23 additions & 0 deletions core/src/components/item-sliding/test/async/item-sliding.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';

test.describe('item-sliding: async', () => {
test('should open even when item is added async', async ({ page, skip }) => {
skip.rtl();
skip.mode('md');

await page.goto(`/src/components/item-sliding/test/async`);

const itemEl = page.locator('ion-item');
const itemSlidingEl = page.locator('ion-item-sliding');

// Wait for item to be added to DOM
await page.waitForSelector('ion-item');

// Click item to open ion-item-sliding
await itemEl.click();

// This class is added when the item sliding component is fully open
await expect(itemSlidingEl).toHaveClass(/item-sliding-active-slide/);
});
});