Skip to content

Commit a0b3ef0

Browse files
authored
fix(item-sliding): account for options added before watcher (#27915)
Issue number: resolves #27910 --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> There is an edge case in our `ion-item-sliding` code where options can be added after the `querySelectorAll` has been run in `updateOptions` but before `watchForOptions` has been called which causes us to miss the newly created options. These options can never be shown as a result. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - `watchForOptions` is called before the initial `updateOptions` call so that we can re-run `updateOptions` in the event that options are added while that first call is running. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Dev build: `7.2.2-dev.11690983626.19a2a8cb`
1 parent 9500769 commit a0b3ef0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

core/src/components/item-sliding/item-sliding.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,19 @@ export class ItemSliding implements ComponentInterface {
7676
this.item = el.querySelector('ion-item');
7777
this.contentEl = findClosestIonContent(el);
7878

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

90+
await this.updateOptions();
91+
8592
this.gesture = (await import('../../utils/gesture')).createGesture({
8693
el,
8794
gestureName: 'item-swipe',

0 commit comments

Comments
 (0)