Skip to content

Commit af1cfdc

Browse files
authored
fix(sidebar): incorrect offset and z-index on mobile (#8856)
remove --z-index-top variable, and split into per-element variables - not everything can be on top! remove some unnecessary z-indexes due to relative positioning I intend to follow up with another commit removing the rest of the reused/unnecessary z-indexes later - but don't want to block fixing this issue with that fixes #8646 fixes #8702
1 parent 093b693 commit af1cfdc

File tree

8 files changed

+31
-26
lines changed

8 files changed

+31
-26
lines changed

Diff for: client/src/app.scss

+17-8
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,21 @@
7878
// + border
7979
--top-banner-outer-height: calc(var(--top-banner-height) + 2 * 1px);
8080

81-
--z-index-back: -1;
82-
--z-index-top: 9999;
81+
/* Z-Indexes
82+
Keep this in order, and avoid reusing variables so elements each
83+
exist on a distinct layer - we hit a lot of bugs if they don't */
8384
--z-index-a11y: 10000;
85+
--z-index-modal-content: 801;
86+
--z-index-modal-overlay: 800;
87+
--z-index-top-banner: 701;
88+
--z-index-main-header: 700;
89+
--z-index-sidebar-mobile: 600;
8490
--z-index-mid: 500;
8591
--z-index-nav-menu: 200;
8692
--z-index-search-results: 101;
8793
--z-index-low: 100;
8894
--z-index-search-results-home: 99;
95+
--z-index-back: -1;
8996

9097
/* Features */
9198
--elem-radius: 0.25rem;
@@ -101,12 +108,14 @@
101108
);
102109
}
103110

104-
.top-banner.visible ~ *,
105-
.top-banner.loading ~ * {
106-
--sticky-header-height: calc(
107-
var(--top-nav-height) + var(--article-actions-container-height) +
108-
var(--top-banner-outer-height) + 2px
109-
);
111+
@media screen and (min-width: $screen-md) {
112+
.top-banner.visible ~ *,
113+
.top-banner.loading ~ * {
114+
--sticky-header-height: calc(
115+
var(--top-nav-height) + var(--article-actions-container-height) +
116+
var(--top-banner-outer-height) + 2px
117+
);
118+
}
110119
}
111120

112121
@media screen and (min-width: $screen-md) {

Diff for: client/src/document/index.scss

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.main-document-header-container {
88
position: sticky;
99
top: 0;
10-
z-index: var(--z-index-top);
10+
z-index: var(--z-index-main-header);
1111
@media screen and (min-width: $screen-md) {
1212
.top-banner.visible ~ &,
1313
.top-banner.loading ~ & {
@@ -645,10 +645,15 @@ kbd {
645645
display: flex;
646646
flex-direction: column;
647647
}
648+
648649
max-height: var(--max-height);
649650
position: sticky;
650651
top: var(--offset);
652+
z-index: var(--z-index-sidebar-mobile);
653+
651654
@media screen and (min-width: $screen-md) {
655+
z-index: auto;
656+
652657
.sidebar {
653658
mask-image: linear-gradient(
654659
to bottom,
@@ -657,6 +662,7 @@ kbd {
657662
rgba(0, 0, 0, 0) 100%
658663
);
659664
}
665+
660666
@media screen and not (min-height: $screen-height-place-limit) {
661667
overflow: auto;
662668
}

Diff for: client/src/document/organisms/sidebar/index.scss

-3
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142
right: 0;
143143
top: var(--offset);
144144
transform: translateX(-100%);
145-
z-index: var(--z-index-top);
146145

147146
.sidebar-inner {
148147
background: var(--background-primary);
@@ -159,7 +158,6 @@
159158
transition: 0.2s linear transform;
160159
width: 80vw;
161160
will-change: transform;
162-
z-index: var(--z-index-top);
163161

164162
.sidebar-inner-nav {
165163
display: contents;
@@ -205,7 +203,6 @@
205203
transition: opacity 0.2s linear;
206204
width: 100%;
207205
will-change: opacity;
208-
z-index: var(--z-index-mid);
209206
}
210207

211208
&.is-animating {

Diff for: client/src/ui/_vars.scss

-9
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,3 @@ $screen-xxl: 1441px;
249249

250250
// screen is to small for sticky placement
251251
$screen-height-place-limit: 44rem;
252-
253-
/*
254-
* z-index scale
255-
*/
256-
$send-to-back: -1;
257-
$bring-to-front: 9999;
258-
$bottom-layer: 100;
259-
$middle-layer: 200;
260-
$top-layer: 300;

Diff for: client/src/ui/atoms/modal/index.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ body.ReactModal__Body--open {
1515
position: fixed;
1616
right: 0;
1717
top: 0;
18-
z-index: var(--z-index-top);
18+
z-index: var(--z-index-modal-overlay);
1919

2020
&.wait {
2121
&,
@@ -30,7 +30,7 @@ body.ReactModal__Body--open {
3030
flex-basis: 32.5rem;
3131
outline: none;
3232
padding: 1.5rem;
33-
z-index: var(--z-index-top);
33+
z-index: var(--z-index-modal-content);
3434
}
3535

3636
.modal-header {

Diff for: client/src/ui/organisms/article-actions/index.scss

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
text-transform: initial;
1212
}
1313

14+
.article-actions-toggle {
15+
display: block;
16+
}
17+
1418
@media screen and (min-width: $screen-md) {
1519
display: block;
1620

Diff for: client/src/ui/organisms/placement/index.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ section.place {
172172
height: var(--top-banner-height);
173173
position: sticky;
174174
top: 0;
175-
z-index: var(--z-index-top);
175+
z-index: var(--z-index-top-banner);
176176

177177
&.fallback {
178178
position: initial;

Diff for: client/src/ui/organisms/top-navigation/index.scss

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
border-bottom: 1px solid var(--border-primary);
66
position: relative;
77
width: 100%;
8-
z-index: $bottom-layer;
98

109
.container {
1110
align-items: center;
@@ -34,7 +33,6 @@
3433

3534
&.show-nav {
3635
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2);
37-
z-index: var(--z-index-top);
3836

3937
.container {
4038
height: auto;

0 commit comments

Comments
 (0)