Skip to content

Commit

Permalink
fix(item): sliding item should not close when clicking an option button
Browse files Browse the repository at this point in the history
fixes #8481
  • Loading branch information
manucorporat committed Oct 6, 2016
1 parent 14e668c commit ec6615d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/components/item/item-sliding-gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ export class ItemSlidingGesture extends PanGesture {
}

notCaptured(ev: any) {
this.closeOpened();
if (!clickedOptionButton(ev)) {
this.closeOpened();
}
}

closeOpened(): boolean {
Expand All @@ -99,9 +101,14 @@ export class ItemSlidingGesture extends PanGesture {
}

function getContainer(ev: any): ItemSliding {
let ele = ev.target.closest('ion-item-sliding', true);
let ele = ev.target.closest('ion-item-sliding');
if (ele) {
return (<any>ele)['$ionComponent'];
}
return null;
}

function clickedOptionButton(ev: any): boolean {
let ele = ev.target.closest('ion-item-options>button');
return !!ele;
}
4 changes: 4 additions & 0 deletions src/components/item/test/sliding/app-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export class E2EPage {
this.list.closeSlidingItems();
}

noclose(item: ItemSliding) {
console.log('no close', item);
}

unread(item: ItemSliding) {
if (item) {
item.close();
Expand Down
4 changes: 2 additions & 2 deletions src/components/item/test/sliding/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ <h2>HubStruck Notifications</h2>
</a>

<ion-item-options side="left">
<button ion-button icon-only (click)="unread(item100)">
<ion-icon name="mail"></ion-icon>
<button ion-button icon-only (click)="noclose(item100)">
No close
</button>
</ion-item-options>
<ion-item-options side="right">
Expand Down

0 comments on commit ec6615d

Please sign in to comment.