Skip to content
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

fix(item-sliding): item-sliding accounts for multiple ion-item elements #23943

Merged
merged 1 commit into from
Sep 16, 2021
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
7 changes: 7 additions & 0 deletions core/src/components/item-sliding/item-sliding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ export class ItemSliding implements ComponentInterface {
}

private onStart() {
/**
* We need to query for the ion-item
* every time the gesture starts. Developers
* may toggle ion-item elements via *ngIf.
*/
this.item = this.el.querySelector('ion-item');

// Prevent scrolling during gesture
this.disableContentScrollY();

Expand Down
26 changes: 26 additions & 0 deletions core/src/components/item-sliding/test/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<ion-button expand="block" onclick="openItem('start')">Open Item Start</ion-button>
<ion-button expand="block" onclick="openItem('end')">Open Item End</ion-button>
<ion-button expand="block" onclick="openItemOneSide()">Open Item with only one side</ion-button>
<ion-button expand="block" onclick="setDynaicItem()">Swap dynamic item</ion-button>
</div>

<ion-list id="list">
Expand Down Expand Up @@ -369,6 +370,17 @@ <h2>RIGHT/LEFT side - many buttons</h2>
</ion-item-options>
</ion-item-sliding>

<ion-item-sliding id="dynamic-item">
<ion-item>
<ion-label>Dynamic First Item</ion-label>
</ion-item>
<ion-item-options side="end">
<ion-item-option color="tertiary" expandable>
First Item Options
</ion-item-option>
</ion-item-options>
</ion-item-sliding>

<ion-item>
<ion-label class="ion-text-wrap">
<h2>Normal ion-item (no sliding)</h2>
Expand All @@ -387,6 +399,20 @@ <h2>Normal button (no sliding)</h2>
</ion-list>

<script>
const setDynaicItem = () => {
const sliding = document.querySelector('#dynamic-item');
sliding.innerHTML = `
<ion-item>
<ion-label>Dynamic Second Item</ion-label>
</ion-item>
<ion-item-options side="end">
<ion-item-option color="tertiary" expandable>
Second Item Options
</ion-item-option>
</ion-item-options>
`
}

var dynamicSlidingEnabled = document.getElementsByClassName('sliding-enabled');

// Toggle the dynamic options
Expand Down