Skip to content

Commit 1c5599b

Browse files
authored
Fix z-index issue with contexts and modals (baserow#4734)
* fix: Append elements to the body instead of prepending them to ensure proper stacking order based on DOM order. * update snapshot
1 parent afa1d8c commit 1c5599b

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

web-frontend/modules/core/mixins/moveToBody.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ export default {
6464
}
6565
} else if (this.$el) {
6666
// Because there is no parent we can directly move the component to the
67-
// top of the body so it will be positioned over any other element.
67+
// end of the body. Elements that mount later are appended after earlier
68+
// ones so that they appear on top when sharing the same z-index (DOM
69+
// order determines visual stacking for equal z-index values).
6870
const body = document.body
69-
body.insertBefore(this.$el, body.firstChild)
71+
body.appendChild(this.$el)
7072
this.fireMovedToBodyHandlers()
7173
}
7274

web-frontend/test/unit/database/components/view/__snapshots__/viewDecoratorContext.spec.js.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ exports[`GridViewRows component with decoration > Should show cant add decorator
122122
viewDecoratorType.onlyForPremium
123123
</div>
124124
</div>
125+
<div
126+
data-v-app=""
127+
id="__nuxt"
128+
>
129+
<!---->
130+
</div>
125131
<div
126132
class="context"
127133
style="top: auto; right: auto; bottom: auto; left: auto;"
@@ -231,12 +237,6 @@ exports[`GridViewRows component with decoration > Should show cant add decorator
231237
</div>
232238
<!--v-if-->
233239
<!--v-if-->
234-
<div
235-
data-v-app=""
236-
id="__nuxt"
237-
>
238-
<!---->
239-
</div>
240240
</body>
241241
`;
242242

@@ -252,6 +252,12 @@ exports[`GridViewRows component with decoration > Should show unavailable decora
252252
viewDecoratorType.onlyForPremium
253253
</div>
254254
</div>
255+
<div
256+
data-v-app=""
257+
id="__nuxt"
258+
>
259+
<!---->
260+
</div>
255261
<div
256262
class="context"
257263
style="top: auto; right: auto; bottom: auto; left: auto;"
@@ -367,12 +373,6 @@ exports[`GridViewRows component with decoration > Should show unavailable decora
367373
</div>
368374
<!--v-if-->
369375
<!--v-if-->
370-
<div
371-
data-v-app=""
372-
id="__nuxt"
373-
>
374-
<!---->
375-
</div>
376376
</body>
377377
`;
378378

0 commit comments

Comments
 (0)