fix(dialog): keep stacked dialogs dismissible
This commit is contained in:
18 files changed
+286
-68
No files matched your search
@@ -319,7 +319,7 @@ watch(
|
|||||||
is a blocking prompt, so keep it above every other layer in the app (the
|
is a blocking prompt, so keep it above every other layer in the app (the
|
||||||
tallest today are the image preview at 80/81 and the sidebar overlays at
|
tallest today are the image preview at 80/81 and the sidebar overlays at
|
||||||
100). -->
|
100). -->
|
||||||
<DialogContent class="flex max-h-[min(36rem,calc(var(--dbx-viewport-height)-2rem))] w-full max-w-[32rem] flex-col gap-4 overflow-hidden" overlay-class="z-[200]" portal-class="z-[200]" :show-close-button="false" @interact-outside.prevent @escape-key-down.prevent>
|
<DialogContent class="flex max-h-[min(36rem,calc(var(--dbx-viewport-height)-2rem))] w-full max-w-[32rem] flex-col gap-4 overflow-hidden" overlay-class="!z-[200]" portal-class="!z-[200]" :show-close-button="false" @interact-outside.prevent @escape-key-down.prevent>
|
||||||
<DialogHeader class="shrink-0">
|
<DialogHeader class="shrink-0">
|
||||||
<DialogTitle>{{ dialogTitle }}</DialogTitle>
|
<DialogTitle>{{ dialogTitle }}</DialogTitle>
|
||||||
<DialogDescription class="text-muted-foreground">
|
<DialogDescription class="text-muted-foreground">
|
||||||
|
|||||||
@@ -159,13 +159,13 @@ describe("SshHostKeyPromptDialog web bridge", () => {
|
|||||||
connectionPositioner.textContent = "New connection";
|
connectionPositioner.textContent = "New connection";
|
||||||
document.body.append(connectionPositioner);
|
document.body.append(connectionPositioner);
|
||||||
|
|
||||||
const promptPositioner = document.body.querySelector<HTMLElement>(".dialog-positioner.z-\\[200\\]");
|
const promptPositioner = document.body.querySelector<HTMLElement>(".dialog-positioner.\\!z-\\[200\\]");
|
||||||
const promptOverlay = document.body.querySelector<HTMLElement>(".dialog-overlay.z-\\[200\\]");
|
const promptOverlay = document.body.querySelector<HTMLElement>(".dialog-overlay.\\!z-\\[200\\]");
|
||||||
expect(promptPositioner).not.toBeNull();
|
expect(promptPositioner).not.toBeNull();
|
||||||
expect(promptOverlay).not.toBeNull();
|
expect(promptOverlay).not.toBeNull();
|
||||||
expect(connectionPositioner.classList.contains("z-50")).toBe(true);
|
expect(connectionPositioner.classList.contains("z-50")).toBe(true);
|
||||||
expect(promptPositioner?.classList.contains("z-[200]")).toBe(true);
|
expect(promptPositioner?.classList.contains("!z-[200]")).toBe(true);
|
||||||
expect(promptOverlay?.classList.contains("z-[200]")).toBe(true);
|
expect(promptOverlay?.classList.contains("!z-[200]")).toBe(true);
|
||||||
expect(document.body.textContent).toContain("layered.example.test:22");
|
expect(document.body.textContent).toContain("layered.example.test:22");
|
||||||
|
|
||||||
const buttons = document.body.querySelectorAll<HTMLButtonElement>("button");
|
const buttons = document.body.querySelectorAll<HTMLButtonElement>("button");
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ onBeforeUnmount(close);
|
|||||||
<ChevronDown v-if="showChevron" class="h-3 w-3 opacity-50" />
|
<ChevronDown v-if="showChevron" class="h-3 w-3 opacity-50" />
|
||||||
</button>
|
</button>
|
||||||
<Teleport to="body">
|
<Teleport to="body">
|
||||||
<div v-if="open" ref="menuRef" class="pointer-events-auto fixed z-50 min-w-32 overflow-x-hidden overflow-y-auto rounded-md p-1 cn-menu-translucent text-popover-foreground" :class="contentClass" :style="menuStyle" role="menu" @pointerdown.prevent>
|
<div v-if="open" ref="menuRef" class="pointer-events-auto fixed z-(--dbx-floating-layer-z-index) min-w-32 overflow-x-hidden overflow-y-auto rounded-md p-1 cn-menu-translucent text-popover-foreground" :class="contentClass" :style="menuStyle" role="menu" @pointerdown.prevent>
|
||||||
<div v-if="label" :class="labelClass">{{ label }}</div>
|
<div v-if="label" :class="labelClass">{{ label }}</div>
|
||||||
<div v-if="label" class="bg-border -mx-1 my-1 h-px" />
|
<div v-if="label" class="bg-border -mx-1 my-1 h-px" />
|
||||||
<template v-for="item in items" :key="item.value">
|
<template v-for="item in items" :key="item.value">
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ watch(
|
|||||||
<div
|
<div
|
||||||
v-if="isOpen"
|
v-if="isOpen"
|
||||||
ref="menuRef"
|
ref="menuRef"
|
||||||
class="ring-foreground/10 fixed z-50 max-h-(--reka-dropdown-menu-content-available-height) min-w-32 overflow-x-hidden overflow-y-auto rounded-md p-1 ring-1 cn-menu-translucent text-popover-foreground"
|
class="ring-foreground/10 fixed z-(--dbx-floating-layer-z-index) max-h-(--reka-dropdown-menu-content-available-height) min-w-32 overflow-x-hidden overflow-y-auto rounded-md p-1 ring-1 cn-menu-translucent text-popover-foreground"
|
||||||
:class="cn(matchTriggerWidth ? 'w-(--reka-dropdown-menu-trigger-width)' : '', contentClass)"
|
:class="cn(matchTriggerWidth ? 'w-(--reka-dropdown-menu-trigger-width)' : '', contentClass)"
|
||||||
:style="menuStyle"
|
:style="menuStyle"
|
||||||
role="menu"
|
role="menu"
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ watch(
|
|||||||
<div
|
<div
|
||||||
v-if="show"
|
v-if="show"
|
||||||
ref="tooltipRef"
|
ref="tooltipRef"
|
||||||
class="fixed z-50 rounded-md text-xs"
|
class="fixed z-(--dbx-floating-layer-z-index) rounded-md text-xs"
|
||||||
:class="cn([tooltipSurfaceClass, slots.content ? '' : ['inline-flex w-fit max-w-xs items-center gap-1.5 px-3 py-1.5', nowrap && !wrapNowrapContent ? 'whitespace-nowrap' : 'break-words'], tooltipTransformClass], contentClass)"
|
:class="cn([tooltipSurfaceClass, slots.content ? '' : ['inline-flex w-fit max-w-xs items-center gap-1.5 px-3 py-1.5', nowrap && !wrapNowrapContent ? 'whitespace-nowrap' : 'break-words'], tooltipTransformClass], contentClass)"
|
||||||
:style="{ left: `${x}px`, top: `${y}px` }"
|
:style="{ left: `${x}px`, top: `${y}px` }"
|
||||||
role="tooltip"
|
role="tooltip"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { HTMLAttributes } from "vue";
|
|||||||
import { reactiveOmit } from "@vueuse/core";
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
import { ContextMenuContent, ContextMenuPortal, useForwardPropsEmits } from "reka-ui";
|
import { ContextMenuContent, ContextMenuPortal, useForwardPropsEmits } from "reka-ui";
|
||||||
import { cn } from "@/lib/common/utils";
|
import { cn } from "@/lib/common/utils";
|
||||||
|
import { useFloatingLayerOrder } from "@/components/ui/dialog/useDialogLayerOrder";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
@@ -15,16 +16,18 @@ const emits = defineEmits<ContextMenuContentEmits>();
|
|||||||
const delegatedProps = reactiveOmit(props, "class");
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
const { forwardRef } = useFloatingLayerOrder();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ContextMenuPortal>
|
<ContextMenuPortal>
|
||||||
<ContextMenuContent
|
<ContextMenuContent
|
||||||
|
:ref="forwardRef"
|
||||||
data-slot="context-menu-content"
|
data-slot="context-menu-content"
|
||||||
v-bind="{ ...$attrs, ...forwarded }"
|
v-bind="{ ...$attrs, ...forwarded }"
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 text-popover-foreground min-w-36 rounded-md p-1 duration-100 cn-menu-translucent z-50 max-h-(--reka-context-menu-content-available-height) origin-(--reka-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto',
|
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 text-popover-foreground min-w-36 rounded-md p-1 duration-100 cn-menu-translucent z-(--dbx-floating-layer-z-index) max-h-(--reka-context-menu-content-available-height) origin-(--reka-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto',
|
||||||
props.class,
|
props.class,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { HTMLAttributes } from "vue";
|
|||||||
import { reactiveOmit } from "@vueuse/core";
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
import { ContextMenuPortal, ContextMenuSubContent, useForwardPropsEmits } from "reka-ui";
|
import { ContextMenuPortal, ContextMenuSubContent, useForwardPropsEmits } from "reka-ui";
|
||||||
import { cn } from "@/lib/common/utils";
|
import { cn } from "@/lib/common/utils";
|
||||||
|
import { useFloatingLayerOrder } from "@/components/ui/dialog/useDialogLayerOrder";
|
||||||
|
|
||||||
const props = defineProps<DropdownMenuSubContentProps & { class?: HTMLAttributes["class"] }>();
|
const props = defineProps<DropdownMenuSubContentProps & { class?: HTMLAttributes["class"] }>();
|
||||||
const emits = defineEmits<DropdownMenuSubContentEmits>();
|
const emits = defineEmits<DropdownMenuSubContentEmits>();
|
||||||
@@ -11,16 +12,18 @@ const emits = defineEmits<DropdownMenuSubContentEmits>();
|
|||||||
const delegatedProps = reactiveOmit(props, "class");
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
const { forwardRef } = useFloatingLayerOrder();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ContextMenuPortal>
|
<ContextMenuPortal>
|
||||||
<ContextMenuSubContent
|
<ContextMenuSubContent
|
||||||
|
:ref="forwardRef"
|
||||||
data-slot="context-menu-sub-content"
|
data-slot="context-menu-sub-content"
|
||||||
v-bind="forwarded"
|
v-bind="forwarded"
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 text-popover-foreground min-w-32 rounded-md ring-foreground/10 ring-1 p-1 duration-100 cn-menu-translucent z-50 origin-(--reka-context-menu-content-transform-origin) overflow-hidden',
|
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 text-popover-foreground min-w-32 rounded-md ring-foreground/10 ring-1 p-1 duration-100 cn-menu-translucent z-(--dbx-floating-layer-z-index) origin-(--reka-context-menu-content-transform-origin) overflow-hidden',
|
||||||
props.class,
|
props.class,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { DialogContentEmits, DialogContentProps } from "reka-ui";
|
import type { DialogContentEmits, DialogContentProps } from "reka-ui";
|
||||||
|
|
||||||
import { ref, type HTMLAttributes } from "vue";
|
import { type HTMLAttributes } from "vue";
|
||||||
import { reactiveOmit } from "@vueuse/core";
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
import { XIcon } from "@lucide/vue";
|
import { XIcon } from "@lucide/vue";
|
||||||
import { DialogClose, DialogContent, DialogDescription, DialogPortal, VisuallyHidden, useForwardPropsEmits } from "reka-ui";
|
import { DialogClose, DialogContent, DialogDescription, DialogPortal, VisuallyHidden, useForwardPropsEmits } from "reka-ui";
|
||||||
@@ -33,14 +33,13 @@ const delegatedProps = reactiveOmit(props, "class", "overlayClass", "portalClass
|
|||||||
|
|
||||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
|
||||||
const positioner = ref<HTMLElement | null>(null);
|
const { layerStyle } = useDialogLayerOrder();
|
||||||
useDialogLayerOrder(positioner);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<DialogPortal>
|
<DialogPortal>
|
||||||
<DialogOverlay :class="props.overlayClass" />
|
<DialogOverlay :class="props.overlayClass" :style="layerStyle" />
|
||||||
<div ref="positioner" data-slot="dialog-positioner" :class="cn('fixed inset-0 z-50 grid place-items-center p-4 pointer-events-none', props.portalClass)">
|
<div data-slot="dialog-positioner" :style="layerStyle" :class="cn('fixed inset-0 z-50 grid place-items-center p-4 pointer-events-none', props.portalClass)">
|
||||||
<DialogContent
|
<DialogContent
|
||||||
data-slot="dialog-content"
|
data-slot="dialog-content"
|
||||||
v-bind="{ ...$attrs, ...forwarded }"
|
v-bind="{ ...$attrs, ...forwarded }"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { DialogContentEmits, DialogContentProps } from "reka-ui";
|
import type { DialogContentEmits, DialogContentProps } from "reka-ui";
|
||||||
|
|
||||||
import { ref, type HTMLAttributes } from "vue";
|
import { type HTMLAttributes } from "vue";
|
||||||
import { reactiveOmit } from "@vueuse/core";
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
import { XIcon } from "@lucide/vue";
|
import { XIcon } from "@lucide/vue";
|
||||||
import { DialogClose, DialogContent, DialogDescription, DialogPortal, VisuallyHidden, useForwardPropsEmits } from "reka-ui";
|
import { DialogClose, DialogContent, DialogDescription, DialogPortal, VisuallyHidden, useForwardPropsEmits } from "reka-ui";
|
||||||
@@ -23,14 +23,13 @@ const delegatedProps = reactiveOmit(props, "class", "showOverlay", "showCloseBut
|
|||||||
|
|
||||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
|
||||||
const positioner = ref<HTMLElement | null>(null);
|
const { layerStyle } = useDialogLayerOrder();
|
||||||
useDialogLayerOrder(positioner);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<DialogPortal>
|
<DialogPortal>
|
||||||
<DialogOverlay v-if="props.showOverlay" />
|
<DialogOverlay v-if="props.showOverlay" :style="layerStyle" />
|
||||||
<div ref="positioner" data-slot="dialog-positioner" class="fixed inset-0 z-50 grid place-items-center p-4 pointer-events-none">
|
<div data-slot="dialog-positioner" :style="layerStyle" class="fixed inset-0 z-50 grid place-items-center p-4 pointer-events-none">
|
||||||
<DialogContent
|
<DialogContent
|
||||||
data-slot="dialog-content"
|
data-slot="dialog-content"
|
||||||
:class="cn('relative z-50 grid max-h-[calc(var(--dbx-viewport-height)-6rem)] w-full max-w-lg my-8 gap-4 rounded-lg border border-border bg-popover text-popover-foreground p-4 shadow-lg duration-200 md:w-full pointer-events-auto', props.class)"
|
:class="cn('relative z-50 grid max-h-[calc(var(--dbx-viewport-height)-6rem)] w-full max-w-lg my-8 gap-4 rounded-lg border border-border bg-popover text-popover-foreground p-4 shadow-lg duration-200 md:w-full pointer-events-auto', props.class)"
|
||||||
|
|||||||
+144
-15
@@ -1,20 +1,40 @@
|
|||||||
// @vitest-environment happy-dom
|
// @vitest-environment happy-dom
|
||||||
|
|
||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { resolve } from "node:path";
|
||||||
import { createApp, defineComponent, h, nextTick, reactive, type Component } from "vue";
|
import { createApp, defineComponent, h, nextTick, reactive, type Component } from "vue";
|
||||||
import { createI18n } from "vue-i18n";
|
import { createI18n } from "vue-i18n";
|
||||||
import { afterEach, describe, expect, it } from "vitest";
|
import { afterEach, describe, expect, it } from "vitest";
|
||||||
import { Dialog, DialogContent, DialogScrollContent, DialogTitle } from "@/components/ui/dialog";
|
import { Dialog, DialogContent, DialogScrollContent, DialogTitle } from "@/components/ui/dialog";
|
||||||
|
import { useFloatingLayerOrder } from "@/components/ui/dialog/useDialogLayerOrder";
|
||||||
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||||
|
|
||||||
const mountedApps: Array<{ unmount: () => void; host: HTMLElement }> = [];
|
const mountedApps: Array<{ unmount: () => void; host: HTMLElement }> = [];
|
||||||
|
const mountedStyles: HTMLStyleElement[] = [];
|
||||||
|
const floatingLayerRule = readFileSync(resolve(process.cwd(), "apps/desktop/src/styles/globals.css"), "utf8").match(/\[data-dbx-floating-layer\]\s*\{[^}]+\}/)?.[0];
|
||||||
|
|
||||||
|
if (!floatingLayerRule) {
|
||||||
|
throw new Error("globals.css is missing the floating layer z-index rule");
|
||||||
|
}
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
for (const { unmount, host } of mountedApps.splice(0)) {
|
for (const { unmount, host } of mountedApps.splice(0)) {
|
||||||
unmount();
|
unmount();
|
||||||
host.remove();
|
host.remove();
|
||||||
}
|
}
|
||||||
|
for (const style of mountedStyles.splice(0)) {
|
||||||
|
style.remove();
|
||||||
|
}
|
||||||
document.body.innerHTML = "";
|
document.body.innerHTML = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function installFloatingLayerStyles() {
|
||||||
|
const style = document.createElement("style");
|
||||||
|
style.textContent = floatingLayerRule;
|
||||||
|
document.head.append(style);
|
||||||
|
mountedStyles.push(style);
|
||||||
|
}
|
||||||
|
|
||||||
async function flush() {
|
async function flush() {
|
||||||
for (let turn = 0; turn < 5; turn += 1) {
|
for (let turn = 0; turn < 5; turn += 1) {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
@@ -23,15 +43,16 @@ async function flush() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Layer = { index: number; slot: string; label: string; element: Element };
|
type Layer = { index: number; slot: string; label: string; zIndex: number; element: Element };
|
||||||
|
|
||||||
/** Dialog layers teleport into `body`, so paint order is their order among the body children. */
|
/** Dialog layers teleport into `body`; their visual order is controlled by z-index. */
|
||||||
function dialogLayers(): Layer[] {
|
function dialogLayers(): Layer[] {
|
||||||
return Array.from(document.body.children)
|
return Array.from(document.body.children)
|
||||||
.map((element, index) => ({
|
.map((element, index) => ({
|
||||||
index,
|
index,
|
||||||
element,
|
element,
|
||||||
slot: element.getAttribute("data-slot") || "",
|
slot: element.getAttribute("data-slot") || "",
|
||||||
|
zIndex: Number.parseInt((element as HTMLElement).style.zIndex || "0", 10),
|
||||||
label: (element.textContent || "")
|
label: (element.textContent || "")
|
||||||
.replace(/\s+/g, " ")
|
.replace(/\s+/g, " ")
|
||||||
.trim()
|
.trim()
|
||||||
@@ -46,8 +67,8 @@ function layer(slot: string, label?: string): Layer {
|
|||||||
return match!;
|
return match!;
|
||||||
}
|
}
|
||||||
|
|
||||||
function overlayBefore(target: Layer): Layer | undefined {
|
function layers(slot: string): Layer[] {
|
||||||
return dialogLayers().find((candidate) => candidate.slot === "dialog-overlay" && candidate.index === target.index - 1);
|
return dialogLayers().filter((candidate) => candidate.slot === slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
function labeledDialog(options: { open: () => boolean; setOpen: (open: boolean) => void; label: string; content: Component }) {
|
function labeledDialog(options: { open: () => boolean; setOpen: (open: boolean) => void; label: string; content: Component }) {
|
||||||
@@ -115,19 +136,21 @@ describe("dialog layer order", () => {
|
|||||||
state.confirmOpen = true;
|
state.confirmOpen = true;
|
||||||
await flush();
|
await flush();
|
||||||
|
|
||||||
// The transfer form and its confirmation paint in open order to begin with.
|
// The transfer form and its confirmation receive layers in open order to begin with.
|
||||||
const transfer = layer("dialog-positioner", "transfer form");
|
const transfer = layer("dialog-positioner", "transfer form");
|
||||||
const confirm = layer("dialog-positioner", "confirm transfer");
|
const confirm = layer("dialog-positioner", "confirm transfer");
|
||||||
expect(confirm.index).toBeGreaterThan(transfer.index);
|
expect(confirm.zIndex).toBeGreaterThan(transfer.zIndex);
|
||||||
expect(overlayBefore(confirm)).toBeDefined();
|
expect(
|
||||||
|
layers("dialog-overlay")
|
||||||
|
.map(({ zIndex }) => zIndex)
|
||||||
|
.sort(),
|
||||||
|
).toEqual([transfer.zIndex, confirm.zIndex].sort());
|
||||||
|
|
||||||
// A dialog that gets remounted (leaving the tracked-transfer dialog and returning to the form)
|
// Reparenting a portal node must not change which dialog is visually on top.
|
||||||
// ends up after the dialog it is supposed to sit below; Reka UI then keeps handing pointer
|
|
||||||
// events to the confirmation dialog while the form's backdrop covers it.
|
|
||||||
const transferOverlay = transfer.element.previousElementSibling!;
|
const transferOverlay = transfer.element.previousElementSibling!;
|
||||||
document.body.append(transferOverlay, transfer.element);
|
document.body.append(transferOverlay, transfer.element);
|
||||||
await flush();
|
await flush();
|
||||||
expect(layer("dialog-positioner", "transfer form").index).toBeGreaterThan(layer("dialog-positioner", "confirm transfer").index);
|
expect(layer("dialog-positioner", "confirm transfer").zIndex).toBeGreaterThan(layer("dialog-positioner", "transfer form").zIndex);
|
||||||
|
|
||||||
// Reopening the confirmation must bring its layer back above the form.
|
// Reopening the confirmation must bring its layer back above the form.
|
||||||
state.confirmOpen = false;
|
state.confirmOpen = false;
|
||||||
@@ -136,9 +159,7 @@ describe("dialog layer order", () => {
|
|||||||
await flush();
|
await flush();
|
||||||
|
|
||||||
const reopened = layer("dialog-positioner", "confirm transfer");
|
const reopened = layer("dialog-positioner", "confirm transfer");
|
||||||
expect(reopened.index).toBeGreaterThan(layer("dialog-positioner", "transfer form").index);
|
expect(reopened.zIndex).toBeGreaterThan(layer("dialog-positioner", "transfer form").zIndex);
|
||||||
expect(document.body.lastElementChild).toBe(reopened.element);
|
|
||||||
expect(overlayBefore(reopened)).toBeDefined();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("paints a nested dialog above the dialog that opened it", async () => {
|
it("paints a nested dialog above the dialog that opened it", async () => {
|
||||||
@@ -185,6 +206,114 @@ describe("dialog layer order", () => {
|
|||||||
state.confirmOpen = true;
|
state.confirmOpen = true;
|
||||||
await flush();
|
await flush();
|
||||||
|
|
||||||
expect(layer("dialog-positioner", "confirm transfer").index).toBeGreaterThan(layer("dialog-positioner", "transfer form").index);
|
const transfer = layer("dialog-positioner", "transfer form");
|
||||||
|
const confirm = layer("dialog-positioner", "confirm transfer");
|
||||||
|
expect(transfer.zIndex).toBeGreaterThan(50);
|
||||||
|
expect(confirm.zIndex).toBeGreaterThan(transfer.zIndex);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("resets the layer sequence after all dialogs close", async () => {
|
||||||
|
const state = mountSiblingDialogs();
|
||||||
|
|
||||||
|
state.transferOpen = true;
|
||||||
|
await flush();
|
||||||
|
expect(layer("dialog-positioner", "transfer form").zIndex).toBe(51);
|
||||||
|
|
||||||
|
state.transferOpen = false;
|
||||||
|
await flush();
|
||||||
|
expect(document.documentElement.style.getPropertyValue("--dbx-dialog-top-z-index")).toBe("50");
|
||||||
|
expect(document.documentElement.style.getPropertyValue("--dbx-floating-layer-z-index")).toBe("51");
|
||||||
|
|
||||||
|
state.transferOpen = true;
|
||||||
|
await flush();
|
||||||
|
expect(layer("dialog-positioner", "transfer form").zIndex).toBe(51);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("exposes a floating layer above the open dialog", async () => {
|
||||||
|
installFloatingLayerStyles();
|
||||||
|
const host = document.createElement("div");
|
||||||
|
document.body.append(host);
|
||||||
|
const state = reactive({ dialogOpen: true, selectOpen: false });
|
||||||
|
const app = createApp(
|
||||||
|
defineComponent({
|
||||||
|
setup() {
|
||||||
|
return () =>
|
||||||
|
h("div", [
|
||||||
|
h(
|
||||||
|
Dialog,
|
||||||
|
{ open: state.dialogOpen, "onUpdate:open": (open: boolean) => (state.dialogOpen = open) },
|
||||||
|
{
|
||||||
|
default: () =>
|
||||||
|
h(DialogContent, null, {
|
||||||
|
default: () => [
|
||||||
|
h(DialogTitle, null, { default: () => "settings" }),
|
||||||
|
h(
|
||||||
|
Select,
|
||||||
|
{ open: state.selectOpen, "onUpdate:open": (open: boolean) => (state.selectOpen = open) },
|
||||||
|
{
|
||||||
|
default: () => [h(SelectTrigger, null, { default: () => h(SelectValue, { placeholder: "Choose" }) }), h(SelectContent, null, { default: () => h(SelectItem, { value: "one" }, { default: () => "One" }) })],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
app.use(createI18n({ legacy: false, locale: "en", messages: { en: {} }, missingWarn: false, fallbackWarn: false }));
|
||||||
|
app.mount(host);
|
||||||
|
mountedApps.push({ unmount: () => app.unmount(), host });
|
||||||
|
await flush();
|
||||||
|
|
||||||
|
const dialog = layer("dialog-positioner", "settings");
|
||||||
|
state.selectOpen = true;
|
||||||
|
await flush();
|
||||||
|
|
||||||
|
const selectContent = document.body.querySelector<HTMLElement>('[data-slot="select-content"]');
|
||||||
|
const popperWrapper = document.body.querySelector<HTMLElement>("[data-reka-popper-content-wrapper]");
|
||||||
|
expect(selectContent).not.toBeNull();
|
||||||
|
expect(popperWrapper?.hasAttribute("data-dbx-floating-layer")).toBe(true);
|
||||||
|
expect(selectContent?.className).toContain("z-(--dbx-floating-layer-z-index)");
|
||||||
|
expect(Number(document.documentElement.style.getPropertyValue("--dbx-floating-layer-z-index"))).toBe(dialog.zIndex + 1);
|
||||||
|
expect(getComputedStyle(popperWrapper!).zIndex).toContain(String(dialog.zIndex + 1));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("preserves an explicit floating layer z-index", async () => {
|
||||||
|
installFloatingLayerStyles();
|
||||||
|
const host = document.createElement("div");
|
||||||
|
document.body.append(host);
|
||||||
|
const FloatingProbe = defineComponent({
|
||||||
|
setup() {
|
||||||
|
const { forwardRef } = useFloatingLayerOrder();
|
||||||
|
return () => h("div", { ref: forwardRef, "data-reka-popper-content-wrapper": "", style: { zIndex: "80" } }, h("div", { style: { zIndex: "80" } }));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const app = createApp(
|
||||||
|
defineComponent({
|
||||||
|
setup() {
|
||||||
|
return () =>
|
||||||
|
h(
|
||||||
|
Dialog,
|
||||||
|
{ open: true },
|
||||||
|
{
|
||||||
|
default: () =>
|
||||||
|
h(DialogContent, null, {
|
||||||
|
default: () => [h(DialogTitle, null, { default: () => "settings" }), h(FloatingProbe)],
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
app.use(createI18n({ legacy: false, locale: "en", messages: { en: {} }, missingWarn: false, fallbackWarn: false }));
|
||||||
|
app.mount(host);
|
||||||
|
mountedApps.push({ unmount: () => app.unmount(), host });
|
||||||
|
await flush();
|
||||||
|
|
||||||
|
const popperWrapper = document.body.querySelector<HTMLElement>("[data-reka-popper-content-wrapper]");
|
||||||
|
expect(popperWrapper?.style.getPropertyValue("--dbx-floating-content-z-index")).toBe("80");
|
||||||
|
expect(getComputedStyle(popperWrapper!).zIndex).toContain("80");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1,39 +1,100 @@
|
|||||||
import { injectDialogRootContext } from "reka-ui";
|
import { injectDialogRootContext, useForwardExpose } from "reka-ui";
|
||||||
import { watch, type Ref } from "vue";
|
import { computed, onBeforeUnmount, onUpdated, ref, watch, watchPostEffect, type Ref } from "vue";
|
||||||
|
|
||||||
|
const BASE_DIALOG_Z_INDEX = 50;
|
||||||
|
const DIALOG_TOP_Z_INDEX_VAR = "--dbx-dialog-top-z-index";
|
||||||
|
const FLOATING_LAYER_Z_INDEX_VAR = "--dbx-floating-layer-z-index";
|
||||||
|
|
||||||
|
const activeDialogLayers = new Map<symbol, Ref<number>>();
|
||||||
|
const topDialogZIndex = ref(BASE_DIALOG_Z_INDEX);
|
||||||
|
|
||||||
|
function syncLayerVariables() {
|
||||||
|
if (typeof document === "undefined") return;
|
||||||
|
|
||||||
|
const root = document.documentElement;
|
||||||
|
root.style.setProperty(DIALOG_TOP_Z_INDEX_VAR, String(topDialogZIndex.value));
|
||||||
|
root.style.setProperty(FLOATING_LAYER_Z_INDEX_VAR, String(topDialogZIndex.value + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshTopDialogZIndex() {
|
||||||
|
let zIndex = BASE_DIALOG_Z_INDEX;
|
||||||
|
// Compact in insertion order even while a parent dialog remains open.
|
||||||
|
for (const layer of activeDialogLayers.values()) layer.value = ++zIndex;
|
||||||
|
topDialogZIndex.value = zIndex;
|
||||||
|
syncLayerVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerDialogLayer(id: symbol, zIndex: Ref<number>) {
|
||||||
|
if (activeDialogLayers.has(id)) return;
|
||||||
|
|
||||||
|
activeDialogLayers.set(id, zIndex);
|
||||||
|
refreshTopDialogZIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
function unregisterDialogLayer(id: symbol) {
|
||||||
|
if (!activeDialogLayers.delete(id)) return;
|
||||||
|
|
||||||
|
refreshTopDialogZIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Keep Reka's positioning wrapper in sync with the floating content's layer. */
|
||||||
|
export function useFloatingLayerOrder() {
|
||||||
|
const { forwardRef, currentElement } = useForwardExpose();
|
||||||
|
|
||||||
|
function syncWrapper() {
|
||||||
|
const element = currentElement.value;
|
||||||
|
const wrapper = element?.hasAttribute("data-reka-popper-content-wrapper") ? element : element?.parentElement;
|
||||||
|
if (!wrapper || (!wrapper.hasAttribute("data-reka-popper-content-wrapper") && element.dataset.alignTrigger !== "true")) return;
|
||||||
|
|
||||||
|
// Reka copies the content's computed z-index to the positioning wrapper.
|
||||||
|
// Read that value before enabling the important override below, otherwise
|
||||||
|
// an existing z-[60]/z-[80] value would be replaced by the live default.
|
||||||
|
const contentElement = wrapper === element ? (element.firstElementChild ?? element) : element;
|
||||||
|
const contentZIndex = Number.parseInt(getComputedStyle(contentElement).zIndex, 10);
|
||||||
|
const wrapperZIndex = Number.parseInt(wrapper.style.zIndex, 10);
|
||||||
|
const preservedZIndex = Math.max(Number.isFinite(contentZIndex) ? contentZIndex : 0, Number.isFinite(wrapperZIndex) ? wrapperZIndex : 0);
|
||||||
|
wrapper.style.setProperty("--dbx-floating-content-z-index", String(preservedZIndex));
|
||||||
|
wrapper.dataset.dbxFloatingLayer = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
watchPostEffect(() => {
|
||||||
|
void topDialogZIndex.value;
|
||||||
|
syncWrapper();
|
||||||
|
});
|
||||||
|
onUpdated(syncWrapper);
|
||||||
|
|
||||||
|
return { forwardRef };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps a dialog layer painted above every dialog that was opened before it.
|
* Keep the visual order of dialogs aligned with Reka UI's logical layer stack.
|
||||||
*
|
*
|
||||||
* `DialogPortal` only teleports its children, it does not gate them on the open state,
|
* Reparenting portal nodes changes only their DOM order. Reka UI keeps a
|
||||||
* so the `fixed inset-0 z-50` wrapper lands in the target as soon as the dialog
|
* separate insertion ordered layer set for pointer-events and outside-click
|
||||||
* *component* mounts. Because all dialog layers share the same z-index, the browser
|
* handling, so reparenting can leave the visible top dialog unreachable. A
|
||||||
* paints them in mount order. A dialog mounted earlier therefore covered one that opens
|
* z-index gives each open dialog a new visual layer while its logical layer
|
||||||
* later: Reka UI's dismissable-layer stack still handed pointer events to the later
|
* remains where Reka UI registered it.
|
||||||
* dialog, so that dialog stayed invisible while the earlier one became unclickable.
|
|
||||||
*
|
|
||||||
* Re-appending the wrapper when its dialog opens makes paint order follow open order
|
|
||||||
* instead of mount order. The element stays mounted on close, so enter/leave animations
|
|
||||||
* are unchanged.
|
|
||||||
*/
|
*/
|
||||||
export function useDialogLayerOrder(positioner: Ref<HTMLElement | null>) {
|
export function useDialogLayerOrder() {
|
||||||
const rootContext = injectDialogRootContext();
|
const rootContext = injectDialogRootContext();
|
||||||
|
const layerId = Symbol("dialog-layer");
|
||||||
function raiseLayer() {
|
const zIndex = ref(BASE_DIALOG_Z_INDEX);
|
||||||
const element = positioner.value;
|
|
||||||
const parent = element?.parentNode;
|
|
||||||
if (!element || !parent || parent.lastElementChild === element) return;
|
|
||||||
// The overlay is the sibling right in front of the wrapper; move both so a later
|
|
||||||
// dialog's backdrop still covers the earlier dialog instead of slipping under it.
|
|
||||||
const overlay = element.previousElementSibling;
|
|
||||||
if (overlay?.getAttribute("data-slot") === "dialog-overlay") parent.appendChild(overlay);
|
|
||||||
parent.appendChild(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => rootContext?.open.value ?? false,
|
() => rootContext?.open.value ?? false,
|
||||||
(isOpen) => {
|
(isOpen) => {
|
||||||
if (isOpen) raiseLayer();
|
if (isOpen) {
|
||||||
|
registerDialogLayer(layerId, zIndex);
|
||||||
|
} else {
|
||||||
|
unregisterDialogLayer(layerId);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ flush: "post" },
|
{ flush: "post", immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
onBeforeUnmount(() => unregisterDialogLayer(layerId));
|
||||||
|
|
||||||
|
return {
|
||||||
|
layerStyle: computed(() => ({ zIndex: String(zIndex.value) })),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import type { HTMLAttributes } from "vue";
|
|||||||
import { reactiveOmit } from "@vueuse/core";
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
import { DropdownMenuContent, DropdownMenuPortal, useForwardPropsEmits } from "reka-ui";
|
import { DropdownMenuContent, DropdownMenuPortal, useForwardPropsEmits } from "reka-ui";
|
||||||
import { cn } from "@/lib/common/utils";
|
import { cn } from "@/lib/common/utils";
|
||||||
|
import { useFloatingLayerOrder } from "@/components/ui/dialog/useDialogLayerOrder";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
@@ -18,16 +19,18 @@ const emits = defineEmits<DropdownMenuContentEmits>();
|
|||||||
const delegatedProps = reactiveOmit(props, "class");
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
const { forwardRef } = useFloatingLayerOrder();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<DropdownMenuPortal>
|
<DropdownMenuPortal>
|
||||||
<DropdownMenuContent
|
<DropdownMenuContent
|
||||||
|
:ref="forwardRef"
|
||||||
data-slot="dropdown-menu-content"
|
data-slot="dropdown-menu-content"
|
||||||
v-bind="{ ...$attrs, ...forwarded }"
|
v-bind="{ ...$attrs, ...forwarded }"
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 text-popover-foreground min-w-32 rounded-md p-1 ring-1 duration-100 cn-menu-translucent z-50 max-h-(--reka-dropdown-menu-content-available-height) w-(--reka-dropdown-menu-trigger-width) origin-(--reka-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto data-[state=closed]:overflow-hidden',
|
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 text-popover-foreground min-w-32 rounded-md p-1 ring-1 duration-100 cn-menu-translucent z-(--dbx-floating-layer-z-index) max-h-(--reka-dropdown-menu-content-available-height) w-(--reka-dropdown-menu-trigger-width) origin-(--reka-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto data-[state=closed]:overflow-hidden',
|
||||||
props.class,
|
props.class,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { HTMLAttributes } from "vue";
|
|||||||
import { reactiveOmit } from "@vueuse/core";
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
import { DropdownMenuSubContent, useForwardPropsEmits } from "reka-ui";
|
import { DropdownMenuSubContent, useForwardPropsEmits } from "reka-ui";
|
||||||
import { cn } from "@/lib/common/utils";
|
import { cn } from "@/lib/common/utils";
|
||||||
|
import { useFloatingLayerOrder } from "@/components/ui/dialog/useDialogLayerOrder";
|
||||||
|
|
||||||
const props = defineProps<DropdownMenuSubContentProps & { class?: HTMLAttributes["class"] }>();
|
const props = defineProps<DropdownMenuSubContentProps & { class?: HTMLAttributes["class"] }>();
|
||||||
const emits = defineEmits<DropdownMenuSubContentEmits>();
|
const emits = defineEmits<DropdownMenuSubContentEmits>();
|
||||||
@@ -11,15 +12,17 @@ const emits = defineEmits<DropdownMenuSubContentEmits>();
|
|||||||
const delegatedProps = reactiveOmit(props, "class");
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
const { forwardRef } = useFloatingLayerOrder();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<DropdownMenuSubContent
|
<DropdownMenuSubContent
|
||||||
|
:ref="forwardRef"
|
||||||
data-slot="dropdown-menu-sub-content"
|
data-slot="dropdown-menu-sub-content"
|
||||||
v-bind="forwarded"
|
v-bind="forwarded"
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 text-popover-foreground min-w-[96px] rounded-md p-1 ring-1 duration-100 cn-menu-translucent z-50 origin-(--reka-dropdown-menu-content-transform-origin) overflow-hidden',
|
'data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 text-popover-foreground min-w-[96px] rounded-md p-1 ring-1 duration-100 cn-menu-translucent z-(--dbx-floating-layer-z-index) origin-(--reka-dropdown-menu-content-transform-origin) overflow-hidden',
|
||||||
props.class,
|
props.class,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { HTMLAttributes } from "vue";
|
|||||||
import { reactiveOmit } from "@vueuse/core";
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
import { PopoverContent, PopoverPortal, useForwardPropsEmits } from "reka-ui";
|
import { PopoverContent, PopoverPortal, useForwardPropsEmits } from "reka-ui";
|
||||||
import { cn } from "@/lib/common/utils";
|
import { cn } from "@/lib/common/utils";
|
||||||
|
import { useFloatingLayerOrder } from "@/components/ui/dialog/useDialogLayerOrder";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
@@ -18,16 +19,18 @@ const emits = defineEmits<PopoverContentEmits>();
|
|||||||
const delegatedProps = reactiveOmit(props, "class");
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
|
|
||||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
const { forwardRef } = useFloatingLayerOrder();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<PopoverPortal>
|
<PopoverPortal>
|
||||||
<PopoverContent
|
<PopoverContent
|
||||||
|
:ref="forwardRef"
|
||||||
data-slot="popover-content"
|
data-slot="popover-content"
|
||||||
v-bind="{ ...$attrs, ...forwarded }"
|
v-bind="{ ...$attrs, ...forwarded }"
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
'bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 flex flex-col gap-2.5 rounded-md p-2.5 text-sm shadow-md ring-1 duration-100 z-50 w-72 origin-(--reka-popover-content-transform-origin) outline-hidden',
|
'bg-popover text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 flex flex-col gap-2.5 rounded-md p-2.5 text-sm shadow-md ring-1 duration-100 z-(--dbx-floating-layer-z-index) w-72 origin-(--reka-popover-content-transform-origin) outline-hidden',
|
||||||
props.class,
|
props.class,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { useSlots } from "vue";
|
|||||||
import { reactiveOmit } from "@vueuse/core";
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
import { SelectContent, SelectPortal, SelectViewport, useForwardPropsEmits } from "reka-ui";
|
import { SelectContent, SelectPortal, SelectViewport, useForwardPropsEmits } from "reka-ui";
|
||||||
import { cn } from "@/lib/common/utils";
|
import { cn } from "@/lib/common/utils";
|
||||||
|
import { useFloatingLayerOrder } from "@/components/ui/dialog/useDialogLayerOrder";
|
||||||
import { SelectScrollDownButton, SelectScrollUpButton } from ".";
|
import { SelectScrollDownButton, SelectScrollUpButton } from ".";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@@ -33,17 +34,19 @@ const slots = useSlots();
|
|||||||
const delegatedProps = reactiveOmit(props, "class", "disablePortal", "hideScrollButtons");
|
const delegatedProps = reactiveOmit(props, "class", "disablePortal", "hideScrollButtons");
|
||||||
|
|
||||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
const { forwardRef } = useFloatingLayerOrder();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<SelectPortal :disabled="disablePortal">
|
<SelectPortal :disabled="disablePortal">
|
||||||
<SelectContent
|
<SelectContent
|
||||||
|
:ref="forwardRef"
|
||||||
data-slot="select-content"
|
data-slot="select-content"
|
||||||
:data-align-trigger="position === 'item-aligned'"
|
:data-align-trigger="position === 'item-aligned'"
|
||||||
v-bind="{ ...$attrs, ...forwarded }"
|
v-bind="{ ...$attrs, ...forwarded }"
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
'text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 min-w-36 rounded-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 cn-menu-translucent relative z-50 max-h-(--reka-select-content-available-height) origin-(--reka-select-content-transform-origin) overflow-x-hidden data-[align-trigger=true]:animate-none',
|
'text-popover-foreground data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 min-w-36 rounded-md ring-1 duration-100 data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2 cn-menu-translucent relative z-(--dbx-floating-layer-z-index) max-h-(--reka-select-content-available-height) origin-(--reka-select-content-transform-origin) overflow-x-hidden data-[align-trigger=true]:animate-none',
|
||||||
slots.header || slots.footer ? 'flex flex-col overflow-y-hidden' : 'overflow-y-auto',
|
slots.header || slots.footer ? 'flex flex-col overflow-y-hidden' : 'overflow-y-auto',
|
||||||
position === 'popper' && 'w-fit min-w-[var(--reka-select-trigger-width)] data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
position === 'popper' && 'w-fit min-w-[var(--reka-select-trigger-width)] data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
||||||
props.class,
|
props.class,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { HTMLAttributes } from "vue";
|
|||||||
import { reactiveOmit } from "@vueuse/core";
|
import { reactiveOmit } from "@vueuse/core";
|
||||||
import { TooltipArrow, TooltipContent, TooltipPortal, useForwardPropsEmits } from "reka-ui";
|
import { TooltipArrow, TooltipContent, TooltipPortal, useForwardPropsEmits } from "reka-ui";
|
||||||
import { cn } from "@/lib/common/utils";
|
import { cn } from "@/lib/common/utils";
|
||||||
|
import { useFloatingLayerOrder } from "@/components/ui/dialog/useDialogLayerOrder";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
@@ -17,16 +18,18 @@ const emits = defineEmits<TooltipContentEmits>();
|
|||||||
|
|
||||||
const delegatedProps = reactiveOmit(props, "class");
|
const delegatedProps = reactiveOmit(props, "class");
|
||||||
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
||||||
|
const { forwardRef } = useFloatingLayerOrder();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<TooltipPortal>
|
<TooltipPortal>
|
||||||
<TooltipContent
|
<TooltipContent
|
||||||
|
:ref="forwardRef"
|
||||||
data-slot="tooltip-content"
|
data-slot="tooltip-content"
|
||||||
v-bind="{ ...forwarded, ...$attrs }"
|
v-bind="{ ...forwarded, ...$attrs }"
|
||||||
:class="
|
:class="
|
||||||
cn(
|
cn(
|
||||||
'data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs has-data-[slot=kbd]:pr-1.5 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm bg-foreground text-background-solid z-50 w-fit max-w-xs origin-(--reka-tooltip-content-transform-origin)',
|
'data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs has-data-[slot=kbd]:pr-1.5 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm bg-foreground text-background-solid z-(--dbx-floating-layer-z-index) w-fit max-w-xs origin-(--reka-tooltip-content-transform-origin)',
|
||||||
props.class,
|
props.class,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ describe("legacy WebView CSS fallbacks", () => {
|
|||||||
expect(dialogContentSource).toContain('data-slot="dialog-positioner"');
|
expect(dialogContentSource).toContain('data-slot="dialog-positioner"');
|
||||||
expect(dialogScrollContentSource).toContain('data-slot="dialog-positioner"');
|
expect(dialogScrollContentSource).toContain('data-slot="dialog-positioner"');
|
||||||
expect(fallback).toContain('[data-slot="dialog-positioner"]');
|
expect(fallback).toContain('[data-slot="dialog-positioner"]');
|
||||||
|
expect(fallback).toContain("z-index: var(--dbx-dialog-top-z-index, 50);");
|
||||||
expect(fallback).toContain("display: flex !important;");
|
expect(fallback).toContain("display: flex !important;");
|
||||||
expect(fallback).toContain("align-items: center !important;");
|
expect(fallback).toContain("align-items: center !important;");
|
||||||
expect(fallback).toContain("justify-content: center !important;");
|
expect(fallback).toContain("justify-content: center !important;");
|
||||||
|
|||||||
@@ -77,6 +77,8 @@
|
|||||||
@import "./tokens.css";
|
@import "./tokens.css";
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
|
--dbx-dialog-top-z-index: 50;
|
||||||
|
--dbx-floating-layer-z-index: 51;
|
||||||
--data-grid-type-integer-fg: #1d4ed8;
|
--data-grid-type-integer-fg: #1d4ed8;
|
||||||
--data-grid-type-numeric-fg: #0e7490;
|
--data-grid-type-numeric-fg: #0e7490;
|
||||||
--data-grid-type-string-fg: #166534;
|
--data-grid-type-string-fg: #166534;
|
||||||
@@ -100,6 +102,12 @@
|
|||||||
--data-grid-type-spatial-fg: #6ee7b7;
|
--data-grid-type-spatial-fg: #6ee7b7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reka caches the content's computed z-index on its positioning wrapper.
|
||||||
|
* Keep it above the live dialog stack through positioning and stack updates. */
|
||||||
|
[data-dbx-floating-layer] {
|
||||||
|
z-index: max(var(--dbx-floating-layer-z-index, 51), var(--dbx-floating-content-z-index, 0)) !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* The column-info tooltip re-derives its type hues from these softer 400-level
|
/* The column-info tooltip re-derives its type hues from these softer 400-level
|
||||||
* values: the 300-level grid-cell palette above is tuned for the data surface
|
* values: the 300-level grid-cell palette above is tuned for the data surface
|
||||||
* and glares on the dark popover. Light mode keeps the 700-level base. */
|
* and glares on the dark popover. Light mode keeps the 700-level base. */
|
||||||
@@ -1826,7 +1834,7 @@ html.dbx-legacy-webview [data-slot="dialog-positioner"] {
|
|||||||
right: 0 !important;
|
right: 0 !important;
|
||||||
bottom: 0 !important;
|
bottom: 0 !important;
|
||||||
left: 0 !important;
|
left: 0 !important;
|
||||||
z-index: 50 !important;
|
z-index: var(--dbx-dialog-top-z-index, 50);
|
||||||
display: flex !important;
|
display: flex !important;
|
||||||
align-items: center !important;
|
align-items: center !important;
|
||||||
justify-content: center !important;
|
justify-content: center !important;
|
||||||
|
|||||||
Reference in new issue
Block a user