Skip to content

Commit

Permalink
fix(modal): fix timing issue when rapidly closing and opening control…
Browse files Browse the repository at this point in the history
…ler modal (#24380)
  • Loading branch information
averyjohnston authored Dec 14, 2021
1 parent e7d0674 commit 732f8e1
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions core/src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,20 @@ export class Modal implements ComponentInterface, OverlayInterface {

if (dismissed) {
const { delegate } = this.getDelegate();
await detachComponent(delegate, this.usersElement);

/**
* If the modal is presented through a controller, we don't need to detach
* since the el was already removed during the `dismiss` call above. Skipping
* this step also prevents an issue where rapdily dismissing right after
* presenting could cause `detachComponent` to be called after the present
* finished, blanking out the newly opened modal.
*
* TODO(FW-423) try and find a way to resolve the race condition directly
*/
if (this.inline) {
await detachComponent(delegate, this.usersElement);
}

if (this.animation) {
this.animation.destroy();
}
Expand All @@ -507,7 +520,6 @@ export class Modal implements ComponentInterface, OverlayInterface {

this.currentTransition = undefined;
this.animation = undefined;

return dismissed;
}

Expand Down

0 comments on commit 732f8e1

Please sign in to comment.