Skip to content

Commit a3cd204

Browse files
authored
fix(overlays): trigger is configured on load (#28526)
Issue number: resolves #28524 --------- <!-- 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. --> Watchers in Stencil are constructed sometime between `connectedCallback` and `componentDidLoad`. If a property is set/changed during that time it is possible for the callback associated with the watcher to not fire because the watcher has not been setup yet. This is most often with `dist-custom-elements` and frameworks such as Angular when using a binding (i.e. `[trigger]` instead of `trigger`) ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - The trigger callback associated with the watcher is manually called in `componentDidLoad` for each overlay. ## 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.5.5-dev.11699974376.13a15397` Note: This is a timing related bug due to a behavior in Stencil, so I did not write automated tests. However, I manually verified that this issue a) reproduces on `main` and b) is fixed with this dev build for each overlay component.
1 parent 5c2a73b commit a3cd204

File tree

7 files changed

+77
-0
lines changed

7 files changed

+77
-0
lines changed

core/src/components/action-sheet/action-sheet.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,17 @@ export class ActionSheet implements ComponentInterface, OverlayInterface {
337337
if (this.isOpen === true) {
338338
raf(() => this.present());
339339
}
340+
341+
/**
342+
* When binding values in frameworks such as Angular
343+
* it is possible for the value to be set after the Web Component
344+
* initializes but before the value watcher is set up in Stencil.
345+
* As a result, the watcher callback may not be fired.
346+
* We work around this by manually calling the watcher
347+
* callback when the component has loaded and the watcher
348+
* is configured.
349+
*/
350+
this.triggerChanged();
340351
}
341352

342353
render() {

core/src/components/alert/alert.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,17 @@ export class Alert implements ComponentInterface, OverlayInterface {
376376
if (this.isOpen === true) {
377377
raf(() => this.present());
378378
}
379+
380+
/**
381+
* When binding values in frameworks such as Angular
382+
* it is possible for the value to be set after the Web Component
383+
* initializes but before the value watcher is set up in Stencil.
384+
* As a result, the watcher callback may not be fired.
385+
* We work around this by manually calling the watcher
386+
* callback when the component has loaded and the watcher
387+
* is configured.
388+
*/
389+
this.triggerChanged();
379390
}
380391

381392
/**

core/src/components/loading/loading.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ export class Loading implements ComponentInterface, OverlayInterface {
225225
if (this.isOpen === true) {
226226
raf(() => this.present());
227227
}
228+
229+
/**
230+
* When binding values in frameworks such as Angular
231+
* it is possible for the value to be set after the Web Component
232+
* initializes but before the value watcher is set up in Stencil.
233+
* As a result, the watcher callback may not be fired.
234+
* We work around this by manually calling the watcher
235+
* callback when the component has loaded and the watcher
236+
* is configured.
237+
*/
238+
this.triggerChanged();
228239
}
229240

230241
disconnectedCallback() {

core/src/components/modal/modal.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,17 @@ export class Modal implements ComponentInterface, OverlayInterface {
368368
raf(() => this.present());
369369
}
370370
this.breakpointsChanged(this.breakpoints);
371+
372+
/**
373+
* When binding values in frameworks such as Angular
374+
* it is possible for the value to be set after the Web Component
375+
* initializes but before the value watcher is set up in Stencil.
376+
* As a result, the watcher callback may not be fired.
377+
* We work around this by manually calling the watcher
378+
* callback when the component has loaded and the watcher
379+
* is configured.
380+
*/
381+
this.triggerChanged();
371382
}
372383

373384
/**

core/src/components/picker/picker.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,17 @@ export class Picker implements ComponentInterface, OverlayInterface {
209209
if (this.isOpen === true) {
210210
raf(() => this.present());
211211
}
212+
213+
/**
214+
* When binding values in frameworks such as Angular
215+
* it is possible for the value to be set after the Web Component
216+
* initializes but before the value watcher is set up in Stencil.
217+
* As a result, the watcher callback may not be fired.
218+
* We work around this by manually calling the watcher
219+
* callback when the component has loaded and the watcher
220+
* is configured.
221+
*/
222+
this.triggerChanged();
212223
}
213224

214225
/**

core/src/components/popover/popover.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,17 @@ export class Popover implements ComponentInterface, PopoverInterface {
370370
this.dismiss(undefined, undefined, false);
371371
});
372372
}
373+
374+
/**
375+
* When binding values in frameworks such as Angular
376+
* it is possible for the value to be set after the Web Component
377+
* initializes but before the value watcher is set up in Stencil.
378+
* As a result, the watcher callback may not be fired.
379+
* We work around this by manually calling the watcher
380+
* callback when the component has loaded and the watcher
381+
* is configured.
382+
*/
383+
this.configureTriggerInteraction();
373384
}
374385

375386
/**

core/src/components/toast/toast.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,17 @@ export class Toast implements ComponentInterface, OverlayInterface {
288288
if (this.isOpen === true) {
289289
raf(() => this.present());
290290
}
291+
292+
/**
293+
* When binding values in frameworks such as Angular
294+
* it is possible for the value to be set after the Web Component
295+
* initializes but before the value watcher is set up in Stencil.
296+
* As a result, the watcher callback may not be fired.
297+
* We work around this by manually calling the watcher
298+
* callback when the component has loaded and the watcher
299+
* is configured.
300+
*/
301+
this.triggerChanged();
291302
}
292303

293304
/**

0 commit comments

Comments
 (0)