Skip to content

Commit 92e53a3

Browse files
authored
fix: Add Safari fix for nested fixed position content within overflowing dialogs. (#4234)
1 parent 52f3157 commit 92e53a3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

components/dialog/dialog-mixin.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
4949
_isFullHeight: { state: true },
5050
_left: { state: true },
5151
_margin: { state: true },
52+
_mobileDropdownShowing: { state: true },
5253
_nestedShowing: { state: true },
5354
_overflowBottom: { state: true },
5455
_overflowTop: { state: true },
@@ -67,12 +68,14 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
6768
this._autoSize = true;
6869
this._dialogId = getUniqueId();
6970
this._fullscreenWithin = 0;
71+
this._handleDropdownOpenClose = this._handleDropdownOpenClose.bind(this);
7072
this._handleMvcDialogOpen = this._handleMvcDialogOpen.bind(this);
7173
this._inIframe = false;
7274
this._isFullHeight = false;
7375
this._height = 0;
7476
this._left = 0;
7577
this._margin = { top: defaultMargin.top, right: defaultMargin.right, bottom: defaultMargin.bottom, left: defaultMargin.left };
78+
this._mobileDropdownShowing = false;
7679
this._nestedShowing = false;
7780
this._overflowBottom = false;
7881
this._overflowTop = false;
@@ -143,6 +146,8 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
143146
_addHandlers() {
144147
window.addEventListener('resize', this._updateSize);
145148
this.addEventListener('touchstart', this._handleTouchStart);
149+
this.addEventListener('d2l-dropdown-open', this._handleDropdownOpenClose, { capture: true });
150+
this.addEventListener('d2l-dropdown-close', this._handleDropdownOpenClose, { capture: true });
146151
if (this.shadowRoot) this.shadowRoot.querySelector('.d2l-dialog-content').addEventListener('scroll', this._updateOverflow);
147152
}
148153

@@ -331,6 +336,10 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
331336
e.stopPropagation();
332337
}
333338

339+
_handleDropdownOpenClose(e) {
340+
this._mobileDropdownShowing = e.composedPath()[0]._useMobileStyling;
341+
}
342+
334343
_handleFocusTrapEnter(e) {
335344
// ignore focus trap events when the target is another element
336345
// to prevent infinite focus loops
@@ -449,6 +458,8 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
449458
_removeHandlers() {
450459
window.removeEventListener('resize', this._updateSize);
451460
this.removeEventListener('touchstart', this._handleTouchStart);
461+
this.removeEventListener('d2l-dropdown-open', this._handleDropdownOpenClose, { capture: true });
462+
this.removeEventListener('d2l-dropdown-close', this._handleDropdownOpenClose, { capture: true });
452463
if (this.shadowRoot) this.shadowRoot.querySelector('.d2l-dialog-content').removeEventListener('scroll', this._updateOverflow);
453464
}
454465

@@ -477,7 +488,8 @@ export const DialogMixin = superclass => class extends RtlMixin(superclass) {
477488
'd2l-dialog-outer-nested-showing': !this._useNative && this._nestedShowing,
478489
'd2l-dialog-outer-scroll': this._scroll,
479490
'd2l-dialog-fullscreen-mobile': info.fullscreenMobile,
480-
'd2l-dialog-fullscreen-within': this._fullscreenWithin !== 0
491+
'd2l-dialog-fullscreen-within': this._fullscreenWithin !== 0,
492+
'd2l-dialog-dropdown-mobile': this._mobileDropdownShowing
481493
};
482494

483495
return html`${this._useNative ?

components/dialog/dialog-styles.js

+4
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ export const dialogStyles = css`
131131
overflow: auto;
132132
}
133133
134+
.d2l-dialog-dropdown-mobile .d2l-dialog-content {
135+
overflow: hidden; /* workaround to fix clipping of nested fixed position elements with overlowing content in Safari bug: https://bugs.webkit.org/show_bug.cgi?id=160953 */
136+
}
137+
134138
.d2l-dialog-footer {
135139
box-sizing: border-box;
136140
flex: none;

0 commit comments

Comments
 (0)