Skip to content

Commit

Permalink
fix: Remove z-index and stacking contexts from list-items (#3775)
Browse files Browse the repository at this point in the history
* Switch list-item z-index to grid order

* Remove fullscreenWithin, dropdownOpen, and tooltipShowing

* Fix lint

* Remove fullscreen-within listener

* Try disabling pointer events

* Fix lint
  • Loading branch information
bearfriend authored Jun 27, 2023
1 parent 7db4fbe commit 6bc1fb4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 38 deletions.
15 changes: 7 additions & 8 deletions components/list/list-item-generic-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
[end actions-end];
grid-template-rows: [main-start] [main-end nested-start] [nested-end];
position: relative;
z-index: 0;
}
::slotted([slot="nested"]) {
Expand All @@ -80,15 +79,15 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
grid-column: control-start / end;
}
:host(.d2l-dragging-over) ::slotted([slot="nested"]) {
z-index: 7; /* must be greater than item's drop-target to allow dropping onto items within nested list */
order: 7; /* must be greater than item's drop-target to allow dropping onto items within nested list */
}
::slotted([slot="drop-target"]) {
height: 100%;
order: 6;
position: absolute;
top: 0;
width: 100%;
z-index: 6;
}
::slotted([slot="outside-control"]),
Expand All @@ -105,7 +104,7 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
::slotted([slot="expand-collapse"]) {
cursor: pointer;
grid-column: expand-collapse-start / expand-collapse-end;
z-index: 2;
order: 2;
}
::slotted([slot="control"]) {
Expand All @@ -124,7 +123,7 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
::slotted([slot="actions"]) {
grid-column: actions-start / actions-end;
justify-self: end;
z-index: 5;
order: 5;
}
::slotted([slot="outside-control-action"]),
Expand All @@ -134,23 +133,23 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
}
::slotted([slot="outside-control-action"]) {
grid-column: start / end;
z-index: 1;
order: 1;
}
:host([no-primary-action]) ::slotted([slot="outside-control-action"]) {
grid-column: start / outside-control-end;
}
::slotted([slot="control-action"]) {
grid-column: control-start / end;
height: 100%;
order: 3;
width: 100%;
z-index: 3;
}
:host([no-primary-action]) ::slotted([slot="control-action"]) {
grid-column: control-start / control-end;
}
::slotted([slot="content-action"]) {
grid-column: content-start / end;
z-index: 4;
order: 4;
}
:host([no-primary-action]) ::slotted([slot="content-action"]) {
display: none;
Expand Down
32 changes: 2 additions & 30 deletions components/list/list-item-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,12 @@ export const ListItemMixin = superclass => class extends composeMixins(
paddingType: { type: String, attribute: 'padding-type' },
_breakpoint: { type: Number },
_displayKeyboardTooltip: { type: Boolean },
_dropdownOpen: { type: Boolean, attribute: '_dropdown-open', reflect: true },
_fullscreenWithin: { type: Boolean, attribute: '_fullscreen-within', reflect: true },
_hovering: { type: Boolean, reflect: true },
_hoveringPrimaryAction: { type: Boolean, attribute: '_hovering-primary-action', reflect: true },
_focusing: { type: Boolean, reflect: true },
_focusingPrimaryAction: { type: Boolean, attribute: '_focusing-primary-action', reflect: true },
_highlight: { type: Boolean, reflect: true },
_highlighting: { type: Boolean, reflect: true },
_tooltipShowing: { type: Boolean, attribute: '_tooltip-showing', reflect: true },
_hasNestedList: { state: true }
};
}
Expand All @@ -108,15 +105,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
display: none;
}
:host([_tooltip-showing]),
:host([_dropdown-open]) {
z-index: 10; /* must be greater than adjacent selected items (if this is increased, d2l-collapsible-panel must be updated too) */
}
:host([_fullscreen-within]) {
position: fixed; /* required for Safari */
z-index: 998; /* must be greater than floating workflow buttons */
}
:host([dragging]) d2l-list-item-generic-layout {
filter: grayscale(75%);
opacity: 0.4;
Expand All @@ -126,9 +114,10 @@ export const ListItemMixin = superclass => class extends composeMixins(
}
[slot="control-container"] {
pointer-events: none;
position: relative;
z-index: -1; /* must allow for interactive content to be accessible with mouse */
}
:host(:first-of-type) [slot="control-container"]::before,
[slot="control-container"]::after {
border-top: 1px solid var(--d2l-color-mica);
Expand Down Expand Up @@ -389,8 +378,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
this._breakpoint = 0;
this._contentId = getUniqueId();
this._displayKeyboardTooltip = false;
this._fullscreenWithin = false;
this._fullscreenWithinCount = 0;
this._hasNestedList = false;
}

Expand Down Expand Up @@ -421,14 +408,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
ro.unobserve(this);
}

firstUpdated(changedProperties) {
this.addEventListener('d2l-dropdown-open', () => this._dropdownOpen = true);
this.addEventListener('d2l-dropdown-close', () => this._dropdownOpen = false);
this.addEventListener('d2l-tooltip-show', () => this._tooltipShowing = true);
this.addEventListener('d2l-tooltip-hide', () => this._tooltipShowing = false);
super.firstUpdated(changedProperties);
}

updated(changedProperties) {
super.updated(changedProperties);
if (changedProperties.has('breakpoints')) {
Expand Down Expand Up @@ -579,12 +558,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
this._focusingPrimaryAction = false;
}

_onFullscreenWithin(e) {
if (e.detail.state) this._fullscreenWithinCount += 1;
else this._fullscreenWithinCount -= 1;
this._fullscreenWithin = (this._fullscreenWithinCount > 0);
}

_onMouseEnter() {
this._hovering = true;
}
Expand Down Expand Up @@ -629,7 +602,6 @@ export const ListItemMixin = superclass => class extends composeMixins(
align-nested="${ifDefined(this.draggable && this.selectable ? 'control' : undefined)}"
@focusin="${this._onFocusIn}"
@focusout="${this._onFocusOut}"
@d2l-fullscreen-within="${this._onFullscreenWithin}"
class="${classMap(classes)}"
data-breakpoint="${this._breakpoint}"
data-separators="${ifDefined(this._separators)}"
Expand Down

0 comments on commit 6bc1fb4

Please sign in to comment.