fix(overlay): stack overlays by open order instead of fixed z-index

This commit is contained in:
Erwan Leboucher authored and 7w1 committed 2026-08-08 21:48:33 -05:00
1 parent 0ce6691870
commit f51c7417a6
79 files changed
+363 -244

No files matched your search

+13
View File
@@ -18,6 +18,19 @@ export default defineConfig({
},
rules: {
'import/no-cycle': ['error', { maxDepth: 3 }],
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'folds',
importNames: ['Overlay', 'PopOut', 'TooltipProvider'],
message:
'Import Overlay/PopOut/TooltipProvider from $components/overlay-stack so they stack by open order.',
},
],
},
],
'import/no-unassigned-import': 'off',
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
+1 -1
View File
@@ -13,11 +13,11 @@ import {
IconButton,
Menu,
percent,
PopOut,
ProgressBar,
Spinner,
Text,
} from 'folds';
import { PopOut } from '$components/overlay-stack';
import FocusTrap from 'focus-trap-react';
import type { SecretStorageKeyContent } from '$types/matrix/accountData';
import { storePrivateKey } from '$client/secretStorageKeys';
+2 -1
View File
@@ -1,4 +1,5 @@
import { TooltipProvider, Tooltip, Box, Text, Badge, toRem } from 'folds';
import { Tooltip, Box, Text, Badge, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
export function BetaNoticeBadge() {
return (
+2 -1
View File
@@ -1,6 +1,7 @@
import FocusTrap from 'focus-trap-react';
import type { RectCords } from 'folds';
import { Box, Button, config, Menu, PopOut, Text } from 'folds';
import { Box, Button, config, Menu, Text } from 'folds';
import { PopOut } from '$components/overlay-stack';
import type { MouseEventHandler, ReactNode } from 'react';
import { useState } from 'react';
import { stopPropagation } from '$utils/keyboard';
+2 -1
View File
@@ -1,7 +1,8 @@
import type { MouseEventHandler, ReactNode } from 'react';
import { useCallback, useState } from 'react';
import type { RectCords } from 'folds';
import { Box, Text, Chip, PopOut, Menu, config, MenuItem, color } from 'folds';
import { Box, Text, Chip, Menu, config, MenuItem, color } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { CaretDown, sizedIcon } from '$components/icons/phosphor';
import FocusTrap from 'focus-trap-react';
import type { SecretStorageKeyContent } from '$types/matrix/accountData';
+4 -3
View File
@@ -12,6 +12,7 @@ import { Box } from 'folds';
import FocusTrap from 'focus-trap-react';
import { useDrag } from '@use-gesture/react';
import * as css from '$features/room/message/styles.css';
import { useOverlayLayer } from '$components/overlay-stack';
import { useDismissOnBack } from '$utils/androidBack';
import { stopPropagation } from '$utils/keyboard';
import { getMobileSheetTiming, useMobileSheetAnimation } from './mobileSheetAnimation';
@@ -28,7 +29,6 @@ interface MobileSwipeDownModalProps {
sheetClassName?: string;
sheetStyle?: CSSProperties;
keyboardAware?: boolean;
zIndex?: number;
overlayDragHandle?: boolean;
}
@@ -105,7 +105,6 @@ export function MobileSwipeDownModal({
sheetClassName,
sheetStyle,
keyboardAware = false,
zIndex,
overlayDragHandle = false,
}: MobileSwipeDownModalProps) {
const sheetRef = useRef<HTMLDivElement>(null);
@@ -115,6 +114,7 @@ export function MobileSwipeDownModal({
const [closing, setClosing] = useState(false);
const closingRef = useRef(false);
const { shouldReduceMotion } = useMobileSheetAnimation();
const zIndex = useOverlayLayer();
// Keyboard and drag offsets share one transform; `bottom` would relayout the subtree.
const applySheetOffset = useCallback(
@@ -367,8 +367,8 @@ export function MobileSwipeDownModal({
}`}
data-gestures="ignore"
style={{
...(closing ? { opacity: 0, transition: 'opacity 100ms ease-out' } : undefined),
zIndex,
...(closing ? { opacity: 0, transition: 'opacity 100ms ease-out' } : undefined),
}}
onClick={handleBackdropClick}
// Touch events deliberately propagate: the drag binds them on `document`, and
@@ -387,6 +387,7 @@ export function MobileSwipeDownModal({
portalRef ? css.MessageMobileOptionsContainerContained : ''
} ${animationCss.SheetEntrance}`}
style={{
zIndex,
...(overlayDragHandle ? { overflow: 'hidden' } : undefined),
...(shouldReduceMotion ? { animation: 'none' } : undefined),
...sheetStyle,
+1 -1
View File
@@ -10,13 +10,13 @@ import {
IconButton,
Input,
Menu,
PopOut,
Scroll,
Spinner,
Text,
as,
config,
} from 'folds';
import { PopOut } from '$components/overlay-stack';
import {
ArrowLeft,
CaretLeft,
+2 -1
View File
@@ -1,7 +1,8 @@
import type { ComponentProps, CSSProperties, ReactNode } from 'react';
import { useEffect, useState } from 'react';
import type { RectCords } from 'folds';
import { Box, Overlay, OverlayBackdrop, OverlayCenter, PopOut } from 'folds';
import { Box, OverlayBackdrop, OverlayCenter } from 'folds';
import { Overlay, PopOut } from '$components/overlay-stack';
import FocusTrap from 'focus-trap-react';
import { useCompactLayout } from '$hooks/useScreenSize';
import { stopPropagation } from '$utils/keyboard';
+3 -11
View File
@@ -1,15 +1,7 @@
import type { ReactNode } from 'react';
import {
Overlay,
OverlayBackdrop,
Box,
config,
Text,
TooltipProvider,
Tooltip,
Chip,
IconButton,
} from 'folds';
import { OverlayBackdrop, Box, config, Text, Tooltip, Chip, IconButton } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { Overlay } from '$components/overlay-stack';
import { sizedIcon, X } from '$components/icons/phosphor';
import FocusTrap from 'focus-trap-react';
+20 -17
View File
@@ -15,6 +15,7 @@ import { WebUpdater } from '$pages/client/WebUpdater';
import { GlobalBannerRenderer } from '$components/global-banner/GlobalBannerRenderer';
import { Toast } from '$components/toast/Toast';
import { ConfirmHost } from '$components/confirm/ConfirmHost';
import { OverlayStackProvider } from '$components/overlay-stack';
import type { ScreenSize } from '$hooks/useScreenSize';
import { ScreenSizeProvider } from '$hooks/useScreenSize';
import { isReactQueryDevtoolsEnabled } from '$pages/reactQueryDevtoolsGate';
@@ -44,23 +45,25 @@ export function AppShell({ children, queryClient, screenSize, jotaiStore }: AppS
<TooltipContainerProvider value={portalContainer ?? undefined}>
<PopOutContainerProvider value={portalContainer ?? undefined}>
<OverlayContainerProvider value={portalContainer ?? undefined}>
<ScreenSizeProvider value={screenSize}>
<QueryClientProvider client={queryClient}>
<JotaiProvider store={jotaiStore}>
<AppShellFrame
portalContainer={portalContainer}
onPortalContainerChange={setPortalContainer}
>
{children}
</AppShellFrame>
</JotaiProvider>
{reactQueryDevtoolsEnabled && (
<Suspense fallback={null}>
<ReactQueryDevtools initialIsOpen={false} />
</Suspense>
)}
</QueryClientProvider>
</ScreenSizeProvider>
<OverlayStackProvider>
<ScreenSizeProvider value={screenSize}>
<QueryClientProvider client={queryClient}>
<JotaiProvider store={jotaiStore}>
<AppShellFrame
portalContainer={portalContainer}
onPortalContainerChange={setPortalContainer}
>
{children}
</AppShellFrame>
</JotaiProvider>
{reactQueryDevtoolsEnabled && (
<Suspense fallback={null}>
<ReactQueryDevtools initialIsOpen={false} />
</Suspense>
)}
</QueryClientProvider>
</ScreenSizeProvider>
</OverlayStackProvider>
</OverlayContainerProvider>
</PopOutContainerProvider>
</TooltipContainerProvider>
@@ -1,18 +1,6 @@
import type { RectCords } from 'folds';
import {
Box,
Button,
Chip,
config,
Input,
Line,
Menu,
MenuItem,
PopOut,
Scroll,
Text,
toRem,
} from 'folds';
import { Box, Button, Chip, config, Input, Line, Menu, MenuItem, Scroll, Text, toRem } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { Plus, X, sizedIcon } from '$components/icons/phosphor';
import { isKeyHotkey } from 'is-hotkey';
import FocusTrap from 'focus-trap-react';
+3 -14
View File
@@ -1,19 +1,8 @@
import FocusTrap from 'focus-trap-react';
import type { RectCords } from 'folds';
import {
Badge,
Box,
config,
IconButton,
Line,
Menu,
PopOut,
Scroll,
Text,
Tooltip,
TooltipProvider,
toRem,
} from 'folds';
import { Badge, Box, config, IconButton, Line, Menu, Scroll, Text, Tooltip, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { PopOut } from '$components/overlay-stack';
import type { MouseEventHandler, ReactNode } from 'react';
import { useEffect, useState } from 'react';
import { useSetting } from '$state/hooks/settings';
@@ -1,5 +1,6 @@
import type { ReactNode } from 'react';
import { Box, Scroll, Line, as, TooltipProvider, Tooltip, Text, IconButton } from 'folds';
import { Box, Scroll, Line, as, Tooltip, Text, IconButton } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import classNames from 'classnames';
import { Image as MediaImage } from '$components/media';
import { sizedIcon, Image as ImageIcon, type PhosphorIcon } from '$components/icons/phosphor';
@@ -1,7 +1,7 @@
import type { ChangeEventHandler, FormEventHandler, KeyboardEventHandler } from 'react';
import { useCallback, useMemo, useRef, useState } from 'react';
import { Overlay } from '$components/overlay-stack';
import {
Overlay,
OverlayBackdrop,
OverlayCenter,
Box,
+3 -1
View File
@@ -6,7 +6,9 @@ import Linkify from 'linkify-react';
import type { Opts } from 'linkifyjs';
import { find } from 'linkifyjs';
import type { RectCords } from 'folds';
import { PopOut, Text, Tooltip, TooltipProvider, toRem } from 'folds';
import { Text, Tooltip, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { PopOut } from '$components/overlay-stack';
import { sanitizeCustomHtml } from '$utils/sanitize';
import { highlightText, scaleSystemEmoji } from '$plugins/react-custom-html-parser';
import { useRoomAbbreviationsContext } from '$hooks/useRoomAbbreviations';
+2 -1
View File
@@ -1,5 +1,6 @@
import type { ComponentProps } from 'react';
import { Text, as, Tooltip, TooltipProvider } from 'folds';
import { Text, as, Tooltip } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import {
timeDayMonYear,
timeHourMinute,
@@ -1,6 +1,7 @@
import type { ReactNode } from 'react';
import { useCallback, useState } from 'react';
import { Box, Button, Modal, Spinner, Text, Tooltip, TooltipProvider, as } from 'folds';
import { Box, Button, Modal, Spinner, Text, Tooltip, as } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { ArrowRight, Download, sizedIcon, Warning } from '$components/icons/phosphor';
import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment';
import type { IFileInfo } from '$types/matrix/common';
@@ -11,12 +11,12 @@ import {
Spinner,
Text,
Tooltip,
TooltipProvider,
as,
color,
config,
toRem,
} from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import {
Eye,
EyeSlash,
@@ -10,10 +10,10 @@ import {
Spinner,
Text,
Tooltip,
TooltipProvider,
as,
config,
} from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { Eye, EyeSlash, menuIcon, sizedIcon, Play, Warning } from '$components/icons/phosphor';
import classNames from 'classnames';
import { isTauri } from '@tauri-apps/api/core';
@@ -1,5 +1,6 @@
import { useAtom } from 'jotai';
import { Overlay, OverlayBackdrop, OverlayCenter, Box, Modal } from 'folds';
import { OverlayBackdrop, OverlayCenter, Box, Modal } from 'folds';
import { Overlay } from '$components/overlay-stack';
import FocusTrap from 'focus-trap-react';
import { stopPropagation } from '$utils/keyboard';
import { useDismissOnBack } from '$utils/androidBack';
@@ -13,7 +13,8 @@ import {
} from '$utils/room/relations';
import { MessageReportItem } from './MessageReport';
import type { RectCords } from 'folds';
import { as, Box, config, IconButton, Line, Menu, MenuItem, PopOut, Text } from 'folds';
import { as, Box, config, IconButton, Line, Menu, MenuItem, Text } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { useMatrixClient } from '$hooks/useMatrixClient';
import {
ArrowBendUpLeftIcon,
@@ -1,7 +1,8 @@
import { useRef } from 'react';
import type { ComponentProps, MutableRefObject, ReactNode } from 'react';
import FocusTrap from 'focus-trap-react';
import { Box, Modal, Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
import { Box, Modal, OverlayBackdrop, OverlayCenter } from 'folds';
import { Overlay } from '$components/overlay-stack';
import { ScreenSize, useScreenSizeOptionally } from '$hooks/useScreenSize';
import { stopPropagation } from '$utils/keyboard';
import { useDismissOnBack } from '$utils/androidBack';
@@ -1,5 +1,6 @@
import { keyframes, style } from '@vanilla-extract/css';
import { color, config, toRem } from 'folds';
import { OVERLAY_LAYER_TOP } from '$components/overlay-stack/layers';
const slideIn = keyframes({
from: {
@@ -34,7 +35,7 @@ export const BannerContainer = style({
top: 'var(--safe-area-inset-top, env(safe-area-inset-top, 0px))',
left: 0,
right: 0,
zIndex: 9999,
zIndex: OVERLAY_LAYER_TOP,
display: 'flex',
flexDirection: 'column',
gap: config.space.S200,
@@ -0,0 +1,81 @@
import { useState } from 'react';
import { act, render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { OVERLAY_LAYER_BASE } from './layers';
import { OverlayStackProvider, useOverlayLayer } from './OverlayStack';
function Layer({ name, children }: { name: string; children?: React.ReactNode }) {
const zIndex = useOverlayLayer();
return (
<div data-testid={name} data-z={zIndex}>
{children}
</div>
);
}
const layerOf = (name: string) => Number(screen.getByTestId(name).dataset.z);
/** `toggled` sits before `steady` in the tree, so tree order and open order disagree. */
function Host({ toggled, steady, initiallyShown }: ToggleHostProps) {
const [shown, setShown] = useState(initiallyShown);
return (
<>
<button type="button" onClick={() => setShown(!initiallyShown)}>
toggle
</button>
{shown && <Layer name={toggled} />}
<Layer name={steady} />
</>
);
}
type ToggleHostProps = { toggled: string; steady: string; initiallyShown: boolean };
const toggle = () => act(() => screen.getByRole('button').click());
describe('useOverlayLayer', () => {
it('puts an overlay opened from inside another above it', () => {
render(
<OverlayStackProvider>
<Layer name="outer">
<Layer name="inner" />
</Layer>
</OverlayStackProvider>
);
expect(layerOf('inner')).toBeGreaterThan(layerOf('outer'));
});
it('orders by open order, not by tree position', () => {
render(
<OverlayStackProvider>
<Host toggled="second" steady="first" initiallyShown={false} />
</OverlayStackProvider>
);
toggle();
expect(layerOf('second')).toBeGreaterThan(layerOf('first'));
});
it('frees the layer again when an overlay closes', () => {
render(
<OverlayStackProvider>
<Host toggled="transient" steady="kept" initiallyShown />
</OverlayStackProvider>
);
const before = layerOf('kept');
toggle();
expect(layerOf('kept')).toBeLessThan(before);
});
it('falls back to the base layer outside a provider', () => {
render(<Layer name="lone" />);
expect(layerOf('lone')).toBe(OVERLAY_LAYER_BASE);
});
});
@@ -0,0 +1,77 @@
import { createContext, useContext, useEffect, useId, useMemo, useRef, useState } from 'react';
import type { ReactNode } from 'react';
import { OVERLAY_LAYER_BASE } from './layers';
type Claim = { id: string; seq: number };
type OverlayStackActions = {
nextSeq: () => number;
claim: (id: string, seq: number) => void;
release: (id: string) => void;
};
const EMPTY_CLAIMS: readonly Claim[] = [];
// Claims are kept apart from the actions so that taking a layer cannot invalidate
// the effect that took it, which would release and re-claim on every change.
const OverlayStackActionsContext = createContext<OverlayStackActions | null>(null);
const OverlayStackClaimsContext = createContext<readonly Claim[]>(EMPTY_CLAIMS);
export function OverlayStackProvider({ children }: { children: ReactNode }) {
const [claims, setClaims] = useState<readonly Claim[]>(EMPTY_CLAIMS);
const seqRef = useRef(0);
const actions = useMemo<OverlayStackActions>(
() => ({
nextSeq: () => {
seqRef.current += 1;
return seqRef.current;
},
claim: (id, seq) =>
setClaims((prev) =>
prev.some((claim) => claim.id === id)
? prev
: [...prev, { id, seq }].sort((a, b) => a.seq - b.seq)
),
release: (id) => setClaims((prev) => prev.filter((claim) => claim.id !== id)),
}),
[]
);
return (
<OverlayStackActionsContext.Provider value={actions}>
<OverlayStackClaimsContext.Provider value={claims}>
{children}
</OverlayStackClaimsContext.Provider>
</OverlayStackActionsContext.Provider>
);
}
/**
* Reserves a layer for as long as `active` holds, and returns the z-index that
* keeps it above every overlay opened before it. Stacking follows open order
* rather than component identity, so no overlay has to know the others exist.
*/
export function useOverlayLayer(active = true): number {
const id = useId();
const actions = useContext(OverlayStackActionsContext);
const claims = useContext(OverlayStackClaimsContext);
const seqRef = useRef<number | null>(null);
// Taken during render, which runs a parent before its children, so an overlay
// opened from inside another sorts above it. Effects run child-first and would
// invert exactly that case. Dropping it while closed lets a reopen go back on top.
if (!active) seqRef.current = null;
else if (seqRef.current === null && actions) seqRef.current = actions.nextSeq();
const seq = seqRef.current;
useEffect(() => {
if (!actions || !active || seq === null) return undefined;
actions.claim(id, seq);
return () => actions.release(id);
}, [actions, active, id, seq]);
// The claim lands in an effect, so the first paint has no place in the stack yet.
const claimed = claims.findIndex((claim) => claim.id === id);
return OVERLAY_LAYER_BASE + (claimed === -1 ? claims.length : claimed);
}
@@ -0,0 +1,33 @@
// oxlint-disable no-restricted-imports -- this file is the wrappers the rule points at
import type { ComponentProps } from 'react';
import {
Overlay as FoldsOverlay,
PopOut as FoldsPopOut,
TooltipProvider as FoldsTooltipProvider,
} from 'folds';
import { useOverlayLayer } from './OverlayStack';
import { OVERLAY_LAYER_TOP } from './layers';
type FoldsOverlayProps = ComponentProps<typeof FoldsOverlay>;
type FoldsPopOutProps = ComponentProps<typeof FoldsPopOut>;
type FoldsTooltipProviderProps = ComponentProps<typeof FoldsTooltipProvider>;
// Folds paints every overlay on one shared layer, leaving portal order to decide
// which of two overlapping ones wins. These take a layer from the overlay stack.
export function Overlay({ style, ...props }: FoldsOverlayProps) {
const zIndex = useOverlayLayer(!!props.open);
return <FoldsOverlay {...props} style={{ zIndex, ...style }} />;
}
export function PopOut({ style, ...props }: FoldsPopOutProps) {
const zIndex = useOverlayLayer(!!props.anchor);
return <FoldsPopOut {...props} style={{ zIndex, ...style }} />;
}
// A trigger stays mounted whether or not its tooltip is showing, so claiming a
// layer per trigger would flood the stack. Tooltips ride above it instead.
export function TooltipProvider({ style, ...props }: FoldsTooltipProviderProps) {
return <FoldsTooltipProvider {...props} style={{ zIndex: OVERLAY_LAYER_TOP, ...style }} />;
}
@@ -0,0 +1,3 @@
export * from './layers';
export * from './OverlayStack';
export * from './StackedOverlay';
@@ -0,0 +1,5 @@
/** Overlays stack from here upwards, clear of the fixed app chrome below 10000. */
export const OVERLAY_LAYER_BASE = 10000;
/** For chrome that must stay visible however deep the overlay stack gets. */
export const OVERLAY_LAYER_TOP = 20000;
+2 -1
View File
@@ -1,5 +1,6 @@
import type { ContainerColor, MainColor } from 'folds';
import { as, Badge, Box, color, Text, Tooltip, TooltipProvider, toRem } from 'folds';
import { as, Badge, Box, color, Text, Tooltip, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import type { ReactNode } from 'react';
import { useId } from 'react';
import { Presence, usePresenceLabel } from '$hooks/useUserPresence';
@@ -1,5 +1,5 @@
import type { RectCords } from 'folds';
import type { PopOut } from 'folds';
import type { PopOut } from '$components/overlay-stack';
import { Box, Button, config, Menu, MenuItem, Scroll, Spinner, Text, toRem } from 'folds';
import { CaretDown, sizedIcon } from '$components/icons/phosphor';
import {
+2 -1
View File
@@ -1,6 +1,7 @@
import classNames from 'classnames';
import type { Position } from 'folds';
import { as, Avatar, Text, Tooltip, TooltipProvider, toRem } from 'folds';
import { as, Avatar, Text, Tooltip, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import type { ComponentProps, ReactNode, RefCallback } from 'react';
import { isMobileOrTablet } from '$utils/platform';
import * as css from './Sidebar.css';
@@ -1,5 +1,6 @@
import { type ReactNode, useCallback, useMemo } from 'react';
import { Box, Button, IconButton, Text, Tooltip, TooltipProvider, toRem, config } from 'folds';
import { Box, Button, IconButton, Text, Tooltip, toRem, config } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { Check, Download, Link, Star, Warning, sizedIcon } from '$components/icons/phosphor';
import { useTimeoutToggle } from '$hooks/useTimeoutToggle';
+2 -1
View File
@@ -3,6 +3,7 @@ import { Box, Text, color, config, toRem } from 'folds';
import { Check, sizedIcon } from '$components/icons/phosphor';
import { useToastMessage } from '$state/toast';
import { OVERLAY_LAYER_TOP } from '$components/overlay-stack';
type ToastProps = {
container: HTMLElement | null;
@@ -22,7 +23,7 @@ export function Toast({ container }: ToastProps) {
display: 'flex',
justifyContent: 'center',
pointerEvents: 'none',
zIndex: 9999,
zIndex: OVERLAY_LAYER_TOP,
}}
>
<Box
@@ -1,6 +1,7 @@
import type { ReactNode } from 'react';
import { useEffect, useMemo, useRef, useState } from 'react';
import { Box, Chip, IconButton, Text, Tooltip, TooltipProvider, color, config, toRem } from 'folds';
import { Box, Chip, IconButton, Text, Tooltip, color, config, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import {
Check,
EyeSlash,
@@ -2,7 +2,8 @@ import type { KeyboardEventHandler } from 'react';
import { useCallback, useEffect, useState, useRef } from 'react';
import type { Room } from '$types/matrix-sdk';
import type { RectCords } from 'folds';
import { Box, Chip, IconButton, PopOut, Spinner, Text, config } from 'folds';
import { Box, Chip, IconButton, Spinner, Text, config } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { Smiley, sizedIcon } from '$components/icons/phosphor';
import { Editor, Transforms } from 'slate';
import { ReactEditor } from 'slate-react';
@@ -1,16 +1,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import {
Box,
IconButton,
Spinner,
Switch,
Text,
Tooltip,
TooltipProvider,
config,
toRem,
} from 'folds';
import { Box, IconButton, Spinner, Switch, Text, Tooltip, config, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { Check, Link, Star, Warning, sizedIcon } from '$components/icons/phosphor';
import { useClientConfig } from '$hooks/useClientConfig';
+2 -1
View File
@@ -1,4 +1,5 @@
import { Box, Chip, IconButton, Spinner, Text, Tooltip, TooltipProvider } from 'folds';
import { Box, Chip, IconButton, Spinner, Text, Tooltip } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import {
Headphones,
sizedIcon,
+2 -1
View File
@@ -1,4 +1,5 @@
import { IconButton, Line, Text, Tooltip, TooltipProvider } from 'folds';
import { IconButton, Line, Text, Tooltip } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import {
ChatCircle,
Headphones,
@@ -1,7 +1,8 @@
import type { ChangeEventHandler, MouseEventHandler } from 'react';
import { useCallback, useMemo, useRef, useState } from 'react';
import type { RectCords } from 'folds';
import { Box, Chip, config, IconButton, Input, PopOut, Scroll, Spinner, Text, toRem } from 'folds';
import { Box, Chip, config, IconButton, Input, Scroll, Spinner, Text, toRem } from 'folds';
import { PopOut } from '$components/overlay-stack';
import {
ArrowsDownUp,
CaretUp,
@@ -2,7 +2,8 @@ import type { MouseEventHandler, ReactNode } from 'react';
import { useState } from 'react';
import FocusTrap from 'focus-trap-react';
import type { RectCords } from 'folds';
import { Box, Button, Chip, Text, PopOut, Menu, Scroll, toRem, config, color } from 'folds';
import { Box, Button, Chip, Text, Menu, Scroll, toRem, config, color } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { SequenceCard, SequenceCardStyle } from '$components/sequence-card';
import { getPowers, usePowerLevelTags } from '$hooks/usePowerLevelTags';
import { SettingTile } from '$components/setting-tile';
@@ -9,14 +9,14 @@ import {
Scroll,
Button,
Input,
PopOut,
Menu,
config,
Spinner,
toRem,
TooltipProvider,
Tooltip,
} from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { PopOut } from '$components/overlay-stack';
import {
ArrowLeft,
chipIcon,
+2 -13
View File
@@ -1,17 +1,6 @@
import { forwardRef, useState } from 'react';
import {
Avatar,
Box,
IconButton,
Line,
Menu,
MenuItem,
Text,
Tooltip,
TooltipProvider,
config,
toRem,
} from 'folds';
import { Avatar, Box, IconButton, Line, Menu, MenuItem, Text, Tooltip, config, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { ResponsiveMenu } from '$components/ResponsiveMenu';
import { useMenuAnchor } from '$hooks/useMenuAnchor';
import { PageHeader } from '$components/page';
+2 -14
View File
@@ -1,19 +1,7 @@
import type { MouseEventHandler, ReactNode } from 'react';
import { useCallback, useRef } from 'react';
import {
Avatar,
Badge,
Box,
Chip,
Line,
Spinner,
Text,
Tooltip,
TooltipProvider,
as,
color,
toRem,
} from 'folds';
import { Avatar, Badge, Box, Chip, Line, Spinner, Text, Tooltip, as, color, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import type { MatrixError, Room, IHierarchyRoom } from '$types/matrix-sdk';
import { JoinRule, KnownMembership } from '$types/matrix-sdk';
import { RoomAvatar, RoomIcon } from '$components/room-avatar';
+2 -14
View File
@@ -1,20 +1,8 @@
import type { MouseEventHandler, ReactNode } from 'react';
import { useCallback, useRef, useState } from 'react';
import type { RectCords } from 'folds';
import {
Box,
Avatar,
Text,
Chip,
as,
Badge,
toRem,
Spinner,
PopOut,
config,
Menu,
MenuItem,
} from 'folds';
import { Box, Avatar, Text, Chip, as, Badge, toRem, Spinner, config, Menu, MenuItem } from 'folds';
import { PopOut } from '$components/overlay-stack';
import classNames from 'classnames';
import type { MatrixError, Room, IHierarchyRoom } from '$types/matrix-sdk';
import type { HierarchyItem } from '$hooks/useSpaceHierarchy';
@@ -7,7 +7,6 @@ import {
Text,
Line,
config,
PopOut,
Menu,
MenuItem,
Header,
@@ -17,6 +16,7 @@ import {
Input,
Badge,
} from 'folds';
import { PopOut } from '$components/overlay-stack';
import FocusTrap from 'focus-trap-react';
import { ResponsiveMenu } from '$components/ResponsiveMenu';
import { useMenuAnchor } from '$hooks/useMenuAnchor';
+1 -1
View File
@@ -9,12 +9,12 @@ import {
Line,
MenuItem,
Modal,
Overlay,
OverlayCenter,
Scroll,
Text,
toRem,
} from 'folds';
import { Overlay } from '$components/overlay-stack';
import { MagnifyingGlass, X, composerIcon, menuIcon } from '$components/icons/phosphor';
import type { ChangeEventHandler, KeyboardEventHandler, MouseEventHandler } from 'react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
+1 -1
View File
@@ -14,8 +14,8 @@ import {
Badge,
Spinner,
Tooltip,
TooltipProvider,
} from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { useFocusWithin, useHover } from 'react-aria';
import { useAtom, useAtomValue } from 'jotai';
import { useNavigate } from 'react-router-dom';
+2 -1
View File
@@ -1,6 +1,7 @@
import { useSetAtom } from 'jotai';
import { useParams } from 'react-router-dom';
import { Box, Text, TooltipProvider, Tooltip, IconButton, toRem } from 'folds';
import { Box, Text, Tooltip, IconButton, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { composerIcon, X } from '$components/icons/phosphor';
import { Page, PageHeader } from '../../components/page';
import { callChatAtom } from '../../state/callEmbed';
+1 -1
View File
@@ -13,10 +13,10 @@ import {
Spinner,
Text,
Tooltip,
TooltipProvider,
config,
toRem,
} from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import type { MatrixClient, Room, RoomMember } from '$types/matrix-sdk';
import { useVirtualizer } from '@tanstack/react-virtual';
import classNames from 'classnames';
+2 -1
View File
@@ -1,4 +1,5 @@
import { IconButton, TooltipProvider, Tooltip, Text } from 'folds';
import { IconButton, Tooltip, Text } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { composerIcon, Phone, VideoCamera } from '$components/icons/phosphor';
import { useAtomValue } from 'jotai';
import type { Room } from '$types/matrix-sdk';
+1 -2
View File
@@ -36,15 +36,14 @@ import {
IconButton,
Menu,
MenuItem,
Overlay,
OverlayBackdrop,
OverlayCenter,
PopOut,
Scroll,
Spinner,
Text,
toRem,
} from 'folds';
import { Overlay, PopOut } from '$components/overlay-stack';
import { useMatrixClient } from '$hooks/useMatrixClient';
import type { AutocompleteQuery } from '$components/editor';
+2 -1
View File
@@ -2,7 +2,8 @@ import type { MouseEventHandler } from 'react';
import { useEffect, useState } from 'react';
import { useAtom } from 'jotai';
import classNames from 'classnames';
import { Box, Avatar, Text, IconButton, Tooltip, TooltipProvider, toRem, Badge } from 'folds';
import { Box, Avatar, Text, IconButton, Tooltip, toRem, Badge } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { useNavigate } from 'react-router-dom';
import type { MatrixEvent } from '$types/matrix-sdk';
import {
@@ -3,19 +3,8 @@ import { useCallback, useMemo, useState } from 'react';
import FocusTrap from 'focus-trap-react';
import { CaretDown, chipIcon, composerIcon, X } from '$components/icons/phosphor';
import type { RectCords } from 'folds';
import {
Dialog,
Header,
config,
Box,
Text,
IconButton,
color,
Button,
Spinner,
Chip,
PopOut,
} from 'folds';
import { Dialog, Header, config, Box, Text, IconButton, color, Button, Spinner, Chip } from 'folds';
import { PopOut } from '$components/overlay-stack';
import type { MatrixError } from '$types/matrix-sdk';
import { Direction, EventType } from '$types/matrix-sdk';
import { useMatrixClient } from '$hooks/useMatrixClient';
+3 -12
View File
@@ -1,17 +1,8 @@
// oxlint-disable no-console
import type { RectCords } from 'folds';
import {
Avatar,
Box,
Chip,
PopOut,
Text,
Tooltip,
TooltipProvider,
as,
config,
toRem,
} from 'folds';
import { Avatar, Box, Chip, Text, Tooltip, as, config, toRem } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { PopOut } from '$components/overlay-stack';
import type { KeyboardEventHandler, MouseEventHandler, MouseEvent, ReactNode } from 'react';
import {
memo,
@@ -2,18 +2,8 @@ import type { KeyboardEventHandler, MouseEventHandler, ReactNode } from 'react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useAtomValue } from 'jotai';
import type { RectCords } from 'folds';
import {
Box,
Chip,
IconButton,
Overlay,
OverlayBackdrop,
PopOut,
Spinner,
Text,
as,
config,
} from 'folds';
import { Box, Chip, IconButton, OverlayBackdrop, Spinner, Text, as, config } from 'folds';
import { Overlay, PopOut } from '$components/overlay-stack';
import { composerIcon, Smiley } from '$components/icons/phosphor';
import { Editor, Transforms } from 'slate';
import { ReactEditor } from 'slate-react';
+2 -3
View File
@@ -3,17 +3,16 @@ import { useCallback, useState } from 'react';
import {
Box,
Modal,
Overlay,
OverlayBackdrop,
OverlayCenter,
PopOut,
Text,
Tooltip,
TooltipProvider,
as,
toRem,
type RectCords,
} from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { Overlay, PopOut } from '$components/overlay-stack';
import classNames from 'classnames';
import type { Room } from '$types/matrix-sdk';
import { type Relations } from '$types/matrix-sdk';
@@ -1,9 +1,6 @@
import { style } from '@vanilla-extract/css';
import { DefaultReset, FocusOutline, color, config, toRem } from 'folds';
// Sheets can be opened from an existing Folds overlay, whose maximum layer is Z9999.
const mobileSheetZIndex = `calc(${config.zIndex.Max} + 1)`;
export const MessageBase = style({
position: 'relative',
maxWidth: '100%',
@@ -96,8 +93,6 @@ export const PreventSelect = style({
userSelect: 'none',
MozUserSelect: 'none',
});
//I have zero clue where these numbers and vars are from but they should be changed
//I just copied the hardcoded value in a more correct place
export const MessageMobileOptionsWrapped = style({
position: 'fixed',
@@ -105,7 +100,6 @@ export const MessageMobileOptionsWrapped = style({
left: 0,
right: 0,
bottom: 0,
zIndex: mobileSheetZIndex,
width: '100vw',
height: '100%',
backgroundColor: color.Other.Overlay,
@@ -121,7 +115,6 @@ export const MessageMobileOptionsContainer = style({
bottom: 0,
left: 0,
right: 0,
zIndex: mobileSheetZIndex,
width: '100%',
maxHeight: '85dvh',
display: 'flex',
@@ -4,7 +4,8 @@ import { useAtomValue } from 'jotai';
import { CaretDown, chipIcon, composerIcon, X } from '$components/icons/phosphor';
import FocusTrap from 'focus-trap-react';
import type { RectCords } from 'folds';
import { Dialog, Header, config, Box, Text, IconButton, color, Button, Chip, PopOut } from 'folds';
import { Dialog, Header, config, Box, Text, IconButton, color, Button, Chip } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { stopPropagation } from '$utils/keyboard';
import { timeDayMonthYear, timeHourMinute, hoursToMs, daysToMs } from '$utils/time';
import { DatePicker, TimePicker } from '$components/time-date';
@@ -2,7 +2,8 @@ import type { KeyboardEventHandler } from 'react';
import { useCallback, useEffect, useState, useRef } from 'react';
import type { Room } from '$types/matrix-sdk';
import type { RectCords } from 'folds';
import { Box, Chip, IconButton, PopOut, Spinner, Text, config } from 'folds';
import { Box, Chip, IconButton, Spinner, Text, config } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { composerIcon, Smiley } from '$components/icons/phosphor';
import { Editor, Transforms } from 'slate';
import { ReactEditor } from 'slate-react';
@@ -1,7 +1,8 @@
import { useEffect, useRef, useState } from 'react';
import type { ChangeEventHandler, KeyboardEventHandler, MouseEventHandler } from 'react';
import type { RectCords } from 'folds';
import { Box, Button, config, Input, Menu, MenuItem, PopOut, Scroll, Text, toRem } from 'folds';
import { Box, Button, config, Input, Menu, MenuItem, Scroll, Text, toRem } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { CaretDown, composerIcon } from '$components/icons/phosphor';
import { isKeyHotkey } from 'is-hotkey';
import FocusTrap from 'focus-trap-react';
@@ -2,6 +2,7 @@ import { fireEvent, render, screen } from '@testing-library/react';
import { SequenceCardStyle } from '$components/sequence-card';
import type { ReactNode } from 'react';
import { describe, expect, it, vi } from 'vitest';
// oxlint-disable-next-line no-restricted-imports
import type * as Folds from 'folds';
import { ScreenSize, ScreenSizeProvider } from '$hooks/useScreenSize';
import { Desktop } from './Desktop';
@@ -2,7 +2,8 @@ import type { MouseEventHandler } from 'react';
import { useEffect, useState, useCallback, useMemo, useRef } from 'react';
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
import type { RectCords } from 'folds';
import { Box, Text, Button, color, config, Badge, Menu, MenuItem, PopOut } from 'folds';
import { Box, Text, Button, color, config, Badge, Menu, MenuItem } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { SequenceCard, SequenceCardStyle } from '$components/sequence-card';
import { debugLoggerEnabledAtom, debugLogsAtom, clearDebugLogsAtom } from '$state/debugLogger';
@@ -2,19 +2,8 @@ import type { MouseEventHandler } from 'react';
import { useCallback, useState } from 'react';
import { isTauri } from '@tauri-apps/api/core';
import type { RectCords } from 'folds';
import {
Badge,
Box,
Button,
Chip,
config,
Spinner,
Text,
IconButton,
PopOut,
Menu,
MenuItem,
} from 'folds';
import { Badge, Box, Button, Chip, config, Spinner, Text, IconButton, Menu, MenuItem } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { DotsThreeOutlineVerticalIcon, menuIcon, X } from '$components/icons/phosphor';
import FocusTrap from 'focus-trap-react';
import type { CryptoApi, VerificationRequest } from '$types/matrix-sdk';
@@ -12,7 +12,6 @@ import {
config,
Spinner,
Menu,
PopOut,
Checkbox,
toRem,
Scroll,
@@ -20,6 +19,7 @@ import {
Line,
Chip,
} from 'folds';
import { PopOut } from '$components/overlay-stack';
import { composerIcon, menuIcon, Plus, Sticker, X } from '$components/icons/phosphor';
import FocusTrap from 'focus-trap-react';
import { useAtomValue } from 'jotai';
@@ -18,12 +18,12 @@ import {
IconButton,
Input,
Menu,
PopOut,
Scroll,
Switch,
Text,
toRem,
} from 'folds';
import { PopOut } from '$components/overlay-stack';
import {
ArrowUp,
composerIcon,
@@ -1,7 +1,8 @@
import type { MouseEventHandler } from 'react';
import { useState } from 'react';
import type { RectCords } from 'folds';
import { Box, config, Header, IconButton, Menu, PopOut, Text } from 'folds';
import { Box, config, Header, IconButton, Menu, Text } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { Info, menuIcon } from '$components/icons/phosphor';
import FocusTrap from 'focus-trap-react';
import { stopPropagation } from '$utils/keyboard';
+1 -1
View File
@@ -9,12 +9,12 @@ import {
Scroll,
Text,
Tooltip,
TooltipProvider,
config,
Button,
Line,
toRem,
} from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import {
ArrowLeft,
composerIcon,
+2 -1
View File
@@ -6,7 +6,8 @@ import type {
} from 'react';
import { useEffect, useRef, useState } from 'react';
import type { RectCords } from 'folds';
import { Header, IconButton, Input, Menu, MenuItem, PopOut, Text, config } from 'folds';
import { Header, IconButton, Input, Menu, MenuItem, Text, config } from 'folds';
import { PopOut } from '$components/overlay-stack';
import { composerIcon, CaretDown } from '$components/icons/phosphor';
import FocusTrap from 'focus-trap-react';
+2 -1
View File
@@ -1,5 +1,6 @@
import { useMemo, useState } from 'react';
import { Box, Switch, Text, Tooltip, TooltipProvider, color, config } from 'folds';
import { Box, Switch, Text, Tooltip, color, config } from 'folds';
import { TooltipProvider } from '$components/overlay-stack';
import { Link, useSearchParams } from 'react-router-dom';
import { SSOAction } from '$types/matrix-sdk';
import { isUsableOAuthMetadata, RegisterFlowStatus, useAuthFlows } from '$hooks/useAuthFlows';
+2 -1
View File
@@ -1,4 +1,5 @@
import { Box, Overlay, OverlayBackdrop, OverlayCenter, Spinner, Text } from 'folds';
import { Box, OverlayBackdrop, OverlayCenter, Spinner, Text } from 'folds';
import { Overlay } from '$components/overlay-stack';
import { useCallback, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import type { ValidatedAuthMetadata } from '$types/matrix-sdk';
@@ -8,14 +8,13 @@ import {
IconButton,
Input,
Menu,
Overlay,
OverlayBackdrop,
OverlayCenter,
PopOut,
Spinner,
Text,
config,
} from 'folds';
import { Overlay, PopOut } from '$components/overlay-stack';
import { sizedIcon, Info } from '$components/icons/phosphor';
import FocusTrap from 'focus-trap-react';
import { Link } from 'react-router-dom';
+2 -1
View File
@@ -1,4 +1,5 @@
import { Box, Overlay, OverlayBackdrop, OverlayCenter, Spinner, Text, color, config } from 'folds';
import { Box, OverlayBackdrop, OverlayCenter, Spinner, Text, color, config } from 'folds';
import { Overlay } from '$components/overlay-stack';
import { sizedIcon, Warning } from '$components/icons/phosphor';
import { useCallback, useEffect } from 'react';
import type { MatrixError } from '$types/matrix-sdk';
@@ -3,13 +3,13 @@ import {
Button,
Checkbox,
Input,
Overlay,
OverlayBackdrop,
OverlayCenter,
Spinner,
Text,
color,
} from 'folds';
import { Overlay } from '$components/overlay-stack';
import type { ChangeEventHandler } from 'react';
import { useCallback, useMemo, useState } from 'react';
import type { AuthDict, IAuthData, MatrixError, RegisterRequest, UIAFlow } from '$types/matrix-sdk';
@@ -5,7 +5,6 @@ import {
Button,
Dialog,
Input,
Overlay,
OverlayBackdrop,
OverlayCenter,
Spinner,
@@ -13,6 +12,7 @@ import {
color,
config,
} from 'folds';
import { Overlay } from '$components/overlay-stack';
import { useNavigate } from 'react-router-dom';
import FocusTrap from 'focus-trap-react';
import type { AuthDict, MatrixError } from '$types/matrix-sdk';
+2 -12
View File
@@ -1,16 +1,6 @@
import type { RectCords } from 'folds';
import {
Box,
Button,
config,
Dialog,
IconButton,
Menu,
MenuItem,
PopOut,
Spinner,
Text,
} from 'folds';
import { Box, Button, config, Dialog, IconButton, Menu, MenuItem, Spinner, Text } from 'folds';
import { PopOut } from '$components/overlay-stack';
import type { MatrixClient } from '$types/matrix-sdk';
import { HttpApiEvent } from '$types/matrix-sdk';
import FocusTrap from 'focus-trap-react';
+1 -1
View File
@@ -10,13 +10,13 @@ import {
Line,
Menu,
MenuItem,
PopOut,
Scroll,
Spinner,
Text,
config,
toRem,
} from 'folds';
import { PopOut } from '$components/overlay-stack';
import {
ArrowLeft,
CaretDown,
+2 -1
View File
@@ -1,7 +1,8 @@
import type { MouseEventHandler } from 'react';
import { useState } from 'react';
import type { RectCords } from 'folds';
import { Box, config, Menu, PopOut, Text } from 'folds';
import { Box, config, Menu, Text } from 'folds';
import { PopOut } from '$components/overlay-stack';
import FocusTrap from 'focus-trap-react';
import { useNavigate } from 'react-router-dom';
import { SidebarAvatar, SidebarItemLeft, SidebarItemTooltip } from '$components/sidebar';
+1 -1
View File
@@ -11,13 +11,13 @@ import {
Line,
Menu,
MenuItem,
PopOut,
Spinner,
Text,
color,
config,
toRem,
} from 'folds';
import { PopOut } from '$components/overlay-stack';
import { FocusTrap } from 'focus-trap-react';
import { ModalOverlay } from '$components/modal-overlay/ModalOverlay';
import { SidebarAvatar, SidebarItem, SidebarItemBadge } from '../../../components/sidebar';
+5 -3
View File
@@ -48,11 +48,13 @@ describe('android edge-to-edge inset contract', () => {
expect(systemBarShell).toContain('ref={onPortalContainerChange}');
});
it('keeps mobile sheets above Folds overlays', () => {
it('layers mobile sheets from the overlay stack rather than a fixed z-index', () => {
const messageStyles = readWorkspaceFile('src/app/features/room/message/styles.css.ts');
const sheet = readWorkspaceFile('src/app/components/MobileSwipeDownModal.tsx');
expect(messageStyles).toContain('const mobileSheetZIndex = `calc(${config.zIndex.Max} + 1)`;');
expect(messageStyles.match(/zIndex: mobileSheetZIndex/g)).toHaveLength(2);
expect(messageStyles).not.toContain('mobileSheetZIndex');
expect(sheet).toContain('const zIndex = useOverlayLayer();');
expect(sheet.match(/zIndex,/g)).toHaveLength(2);
});
it('uses the App shell as the only safe-area owner', () => {