Skip to content

Commit

Permalink
fix(item-sliding): account for options added before watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
liamdebeasi committed Aug 2, 2023
1 parent 0c117cf commit 9a2a8cb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions core/src/components/item-sliding/item-sliding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,19 @@ export class ItemSliding implements ComponentInterface {
this.item = el.querySelector('ion-item');
this.contentEl = findClosestIonContent(el);

await this.updateOptions();

/**
* The MutationObserver needs to be added before we
* call updateOptions below otherwise we may miss
* ion-item-option elements that are added to the DOM
* while updateOptions is running and before the MutationObserver
* has been initialized.
*/
this.mutationObserver = watchForOptions<HTMLIonItemOptionElement>(el, 'ion-item-option', async () => {
await this.updateOptions();
});

await this.updateOptions();

this.gesture = (await import('../../utils/gesture')).createGesture({
el,
gestureName: 'item-swipe',
Expand Down Expand Up @@ -237,6 +244,7 @@ export class ItemSliding implements ComponentInterface {
}

private async updateOptions() {
console.log('update');
const options = this.el.querySelectorAll('ion-item-options');

let sides = 0;
Expand Down

0 comments on commit 9a2a8cb

Please sign in to comment.