Skip to content

Commit f85ca5e

Browse files
fix: don't fade out if the backdrop hasn't faded in (#6630)
1 parent 94dea7a commit f85ca5e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

components/backdrop/backdrop-loading.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class LoadingBackdrop extends LitElement {
6464
:host([_state="shown"]) d2l-loading-spinner {
6565
opacity: 1;
6666
}
67-
67+
6868
:host([_state="hiding"]) .d2l-backdrop,
6969
:host([_state="hiding"]) d2l-loading-spinner {
7070
transition: opacity ${FADE_DURATION_MS}ms ease-out;
@@ -111,7 +111,13 @@ class LoadingBackdrop extends LitElement {
111111
}
112112

113113
#fade() {
114-
if (reduceMotion || this._state === 'showing') {
114+
let hideImmediately = reduceMotion || this._state === 'showing';
115+
if (this._state === 'shown') {
116+
const currentOpacity = getComputedStyle(this.shadowRoot.querySelector('.backdrop')).opacity;
117+
hideImmediately ||= (currentOpacity === '0');
118+
}
119+
120+
if (hideImmediately) {
115121
this.#hide();
116122
} else {
117123
this._state = 'hiding';

0 commit comments

Comments
 (0)