Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(web): animate the active mobile user bar extension (#787)

Gustavo Yeb2497b162288
diff --git a/src/web/src/app/globals.css b/src/web/src/app/globals.css
index a3401d82c..e0441a72b 100644
--- a/src/web/src/app/globals.css
+++ b/src/web/src/app/globals.css
@@ -3029,27 +3029,27 @@ body {
}
}
-.community-inbox-drawer-viewport {
+.community-user-bar-drawer-viewport {
clip-path: inset(-24px -24px 0 -24px);
}
-.community-inbox-drawer {
+.community-user-bar-drawer {
animation: none;
transform: translateY(0);
transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
-.community-inbox-drawer[data-starting-style],
-.community-inbox-drawer[data-ending-style] {
+.community-user-bar-drawer[data-starting-style],
+.community-user-bar-drawer[data-ending-style] {
transform: translateY(100%);
}
-.community-inbox-drawer[data-ending-style] {
+.community-user-bar-drawer[data-ending-style] {
transition-duration: 180ms;
}
@media (prefers-reduced-motion: reduce) {
- .community-inbox-drawer {
+ .community-user-bar-drawer {
transition: none;
}
}
diff --git a/src/web/src/components/community/shell/community-inbox-surface.dom.test.ts b/src/web/src/components/community/shell/community-inbox-surface.dom.test.ts
deleted file mode 100644
index 3b910807f..000000000
--- a/src/web/src/components/community/shell/community-inbox-surface.dom.test.ts
+++ /dev/null
@@ -1,149 +0,0 @@
-import { cloneElement, createElement, createRef, type PropsWithChildren, type ReactElement, type ReactNode } from "react"
-import { describe, expect, it, vi } from "vitest"
-import { act, render } from "@/test/react-dom-harness"
-import { CommunityInboxSurface } from "./community-inbox-surface"
-import { tid } from "@/lib/community/testids"
-
-const surfaceProps = vi.hoisted(() => new Map<string, Record<string, unknown>>())
-
-vi.mock("@/components/ui/popover", () => {
- const pass = (type: string) =>
- function Pass({ children, ...props }: PropsWithChildren<Record<string, unknown>>) {
- surfaceProps.set(type, props)
- return createElement(type, props, children)
- }
- return {
- Popover: pass("popover-root"),
- PopoverContent: pass("popover-content"),
- PopoverPopup: pass("popover-popup"),
- PopoverPortal: pass("popover-portal"),
- PopoverPositioner: pass("popover-positioner"),
- PopoverTitle: pass("popover-title"),
- PopoverTrigger: ({ children, render: trigger }: { children?: ReactNode; render: ReactElement }) => {
- surfaceProps.set("popover-trigger", { render: trigger })
- return cloneElement(trigger, undefined, children)
- },
- }
-})
-
-async function renderSurface(breakpoint: "mobile" | "desktop", open = true) {
- const anchorRef = createRef<HTMLDivElement>()
- const suppressFocusReturnRef = { current: false }
- const onOpenChange = vi.fn()
- surfaceProps.clear()
- const renderer = render(createElement(CommunityInboxSurface, {
- breakpoint,
- open,
- onOpenChange,
- hasUnread: true,
- anchorRef,
- suppressFocusReturnRef,
- }, createElement("inbox-content")))
- return { renderer, anchorRef, suppressFocusReturnRef, onOpenChange }
-}
-
-describe("CommunityInboxSurface", () => {
- it("uses a backdrop-free nonmodal Popover surface on mobile", async () => {
- const { renderer, anchorRef, suppressFocusReturnRef } = await renderSurface("mobile")
- expect(surfaceProps.get("popover-root")?.modal).toBe(false)
- const trigger = renderer.getByTestId(tid.inboxTrigger)
- const triggerClasses = trigger.className.split(" ")
- expect(trigger).toHaveAttribute("aria-label", "Close Inbox")
- expect(trigger).toHaveAttribute("aria-pressed", "true")
- expect(trigger.className).toContain("aria-expanded:text-foreground")
- expect(triggerClasses).not.toContain("hover:bg-accent")
- expect(triggerClasses).toContain("hover:text-foreground")
- expect(triggerClasses).toContain("active:text-foreground")
- expect(triggerClasses).not.toContain("border")
- expect(triggerClasses).not.toContain("bg-accent")
- expect(triggerClasses).not.toContain("shadow")
- expect(triggerClasses).toContain("focus-visible:ring-2")
- const icon = trigger.querySelector("svg")!
- expect(icon.getAttribute("class")).not.toContain("fill-current")
- expect(icon).toHaveAttribute("fill", "none")
- const unreadDot = trigger.querySelector<HTMLElement>("span.bg-primary")!
- expect(unreadDot.className.split(" ")).toEqual(expect.arrayContaining([
- "-right-1",
- "-top-1",
- ]))
- expect(unreadDot.parentElement?.className.split(" ")).toEqual(expect.arrayContaining([
- "relative",
- "size-4",
- ]))
- expect(renderer.container.querySelectorAll("popover-backdrop")).toHaveLength(0)
-
- const positioner = surfaceProps.get("popover-positioner")
- expect(positioner).toMatchObject({
- anchor: anchorRef,
- positionMethod: "fixed",
- side: "top",
- align: "start",
- sideOffset: 0,
- collisionAvoidance: { side: "none", align: "none", fallbackAxisSide: "none" },
- })
- const popup = surfaceProps.get("popover-popup")!
- expect(popup["data-testid"]).toBe(tid.inboxMobileSurface)
- expect(popup.initialFocus).toBe(false)
- expect(popup.className).toContain("w-(--anchor-width)")
- expect(renderer.container.querySelector("popover-title")).toHaveTextContent("Inbox")
- expect(renderer.container.querySelectorAll("popover-close")).toHaveLength(0)
- const card = renderer.getByTestId(tid.inboxMobileCard)
- expect(card.className).toContain("rounded-t-xl")
- expect(card.className).not.toContain("rounded-xl")
- expect(card.style.height)
- .toContain("100dvh")
-
- suppressFocusReturnRef.current = true
- expect((popup.finalFocus as () => boolean)()).toBe(false)
- })
-
- it("keeps the mobile trigger outlined while closed", async () => {
- const { renderer } = await renderSurface("mobile", false)
- const trigger = renderer.getByTestId(tid.inboxTrigger)
- expect(trigger).toHaveAttribute("aria-label", "Open Inbox")
- expect(trigger).toHaveAttribute("aria-pressed", "false")
- expect(trigger.className).toContain("aria-expanded:text-foreground")
- expect(trigger.className.split(" ")).not.toContain("hover:bg-accent")
- expect(trigger.querySelector("svg")?.getAttribute("class")).not.toContain("fill-current")
- expect(trigger.querySelector("svg")).toHaveAttribute("fill", "none")
- })
-
- it("keeps the exact anchored desktop Popover path", async () => {
- const { renderer } = await renderSurface("desktop")
- const content = surfaceProps.get("popover-content")!
- expect(content).toMatchObject({ side: "top", align: "end" })
- expect(content.className).toBe(
- "w-90 max-w-[calc(100vw-1rem)] overflow-hidden p-0",
- )
- const trigger = renderer.getByTestId(tid.inboxTrigger)
- expect(trigger).toHaveAttribute("aria-label", "Inbox")
- expect(trigger).not.toHaveAttribute("aria-pressed")
- expect(trigger.className).not.toContain("aria-expanded:text-foreground")
- expect(trigger.className.split(" ")).toContain("hover:bg-accent")
- expect(trigger.querySelector("svg")?.getAttribute("class")).not.toContain("fill-current")
- const unreadDot = trigger.querySelector<HTMLElement>("span.bg-primary")!
- const unreadDotClasses = unreadDot.className.split(" ")
- expect(unreadDotClasses).toEqual(expect.arrayContaining([
- "right-1",
- "top-1",
- ]))
- expect(unreadDotClasses).not.toContain("-right-1")
- expect(unreadDotClasses).not.toContain("-top-1")
- expect(renderer.container.querySelectorAll("popover-backdrop")).toHaveLength(0)
- expect(renderer.container.querySelectorAll("popover-popup")).toHaveLength(0)
- })
-
- it("keeps open ownership controlled and resets focus suppression on reopen", async () => {
- const { renderer, suppressFocusReturnRef, onOpenChange } = await renderSurface("mobile")
- suppressFocusReturnRef.current = true
- await act(async () => (surfaceProps.get("popover-root")?.onOpenChange as (
- open: boolean,
- details: { reason: string; event: Event },
- ) => void)(true, {
- reason: "trigger-press",
- event: new Event("click"),
- }))
- expect(suppressFocusReturnRef.current).toBe(false)
- expect(onOpenChange).toHaveBeenCalledWith(true)
- })
-})
diff --git a/src/web/src/components/community/shell/community-inbox-surface.tsx b/src/web/src/components/community/shell/community-inbox-surface.tsx
deleted file mode 100644
index ff402de5e..000000000
--- a/src/web/src/components/community/shell/community-inbox-surface.tsx
+++ /dev/null
@@ -1,140 +0,0 @@
-"use client"
-
-import { useRef, type MutableRefObject, type ReactNode, type RefObject } from "react"
-import { Inbox } from "lucide-react"
-import {
- Popover,
- PopoverContent,
- PopoverPopup,
- PopoverPortal,
- PopoverPositioner,
- PopoverTitle,
- PopoverTrigger,
-} from "@/components/ui/popover"
-import type { Breakpoint } from "@/hooks/use-mobile"
-import { tid } from "@/lib/community/testids"
-import { cn } from "@/lib/utils"
-import { COMMUNITY_USER_BAR_HEIGHT_CSS } from "./shell-frame-geometry"
-import { selectUnreadPresentation } from "@/hooks/community/unread-presentation"
-
-type Props = {
- breakpoint: Breakpoint
- open?: boolean
- onOpenChange?: (open: boolean) => void
- hasUnread: boolean
- anchorRef: RefObject<HTMLDivElement | null>
- suppressFocusReturnRef: MutableRefObject<boolean>
- children: ReactNode
-}
-
-export function CommunityInboxSurface({
- breakpoint,
- open,
- onOpenChange,
- hasUnread,
- anchorRef,
- suppressFocusReturnRef,
- children,
-}: Props) {
- const triggerRef = useRef<HTMLButtonElement>(null)
- const mobile = breakpoint === "mobile"
- const unread = selectUnreadPresentation({ accountUnread: hasUnread })
-
- return (
- <Popover
- open={open}
- modal={false}
- onOpenChange={(nextOpen, details) => {
- if (nextOpen) suppressFocusReturnRef.current = false
- else if (
- details.reason === "outside-press"
- && typeof Element !== "undefined"
- && details.event.target instanceof Element
- && details.event.target.closest(`[data-testid='${tid.userBar}']`)
- ) {
- suppressFocusReturnRef.current = true
- }
- onOpenChange?.(nextOpen)
- }}
- >
- <PopoverTrigger
- render={
- <button
- ref={triggerRef}
- data-testid={tid.inboxTrigger}
- className={cn(
- "relative grid size-11 place-items-center rounded-lg text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none sm:size-7",
- mobile
- ? "hover:text-foreground active:text-foreground aria-expanded:text-foreground"
- : "hover:bg-accent hover:text-foreground",
- )}
- aria-label={mobile ? (open ? "Close Inbox" : "Open Inbox") : "Inbox"}
- aria-pressed={mobile ? open : undefined}
- />
- }
- >
- {mobile ? (
- <span className="relative grid size-4 place-items-center">
- <Inbox className="size-4" />
- {unread.showDot && (
- <span className="absolute -right-1 -top-1 size-2 rounded-full bg-primary" />
- )}
- </span>
- ) : (
- <>
- <Inbox className="size-4" />
- {unread.showDot && (
- <span className="absolute right-1 top-1 size-2 rounded-full bg-primary" />
- )}
- </>
- )}
- </PopoverTrigger>
-
- {mobile ? (
- <PopoverPortal>
- <PopoverPositioner
- className="community-inbox-drawer-viewport"
- anchor={anchorRef}
- positionMethod="fixed"
- side="top"
- align="start"
- sideOffset={0}
- collisionAvoidance={{
- side: "none",
- align: "none",
- fallbackAxisSide: "none",
- }}
- >
- <PopoverPopup
- data-testid={tid.inboxMobileSurface}
- initialFocus={false}
- finalFocus={() => (
- suppressFocusReturnRef.current ? false : triggerRef.current
- )}
- className="community-inbox-drawer w-(--anchor-width) origin-bottom border-0 bg-transparent p-0 shadow-none"
- >
- <PopoverTitle className="sr-only">Inbox</PopoverTitle>
- <div
- data-testid={tid.inboxMobileCard}
- className="relative min-h-0 overflow-hidden rounded-t-xl border border-border bg-popover text-popover-foreground shadow-(--e2)"
- style={{
- height: `min(28rem, max(0px, calc(100dvh - ${COMMUNITY_USER_BAR_HEIGHT_CSS} - var(--app-safe-area-top))))`,
- }}
- >
- {children}
- </div>
- </PopoverPopup>
- </PopoverPositioner>
- </PopoverPortal>
- ) : (
- <PopoverContent
- side="top"
- align="end"
- className="w-90 max-w-[calc(100vw-1rem)] overflow-hidden p-0"
- >
- {children}
- </PopoverContent>
- )}
- </Popover>
- )
-}
diff --git a/src/web/src/components/community/shell/user-bar-extension-drawer.tsx b/src/web/src/components/community/shell/user-bar-extension-drawer.tsx
new file mode 100644
index 000000000..b8a597305
--- /dev/null
+++ b/src/web/src/components/community/shell/user-bar-extension-drawer.tsx
@@ -0,0 +1,21 @@
+"use client"
+
+import { cloneElement, useState, type ReactElement } from "react"
+import { Collapsible } from "@base-ui/react/collapsible"
+
+type Content = ReactElement<{ interactive?: boolean; animate?: boolean }>
+
+export function UserBarExtensionDrawer({ children }: { children: Content | null }) {
+ const [retained, setRetained] = useState(children)
+ if (children && children !== retained) setRetained(children)
+ const open = children !== null
+ const content = children ?? retained
+
+ return (
+ <Collapsible.Root open={open} className="community-user-bar-drawer-viewport">
+ <Collapsible.Panel className="community-user-bar-drawer" inert={!open}>
+ {content && cloneElement(content, { interactive: open, animate: false })}
+ </Collapsible.Panel>
+ </Collapsible.Root>
+ )
+}
diff --git a/src/web/src/components/community/shell/user-bar-extension-slot.dom.test.tsx b/src/web/src/components/community/shell/user-bar-extension-slot.dom.test.tsx
index 01bc2b0f5..e20efef66 100644
--- a/src/web/src/components/community/shell/user-bar-extension-slot.dom.test.tsx
+++ b/src/web/src/components/community/shell/user-bar-extension-slot.dom.test.tsx
@@ -34,6 +34,31 @@ const machines = [{
}]
describe("UserBarExtensionSlot", () => {
+ it("disables dismissal and focus while retained for the closing animation", async () => {
+ const onDismiss = vi.fn()
+ const onInitialFocus = vi.fn()
+ const props = {
+ active: "profile" as const,
+ profile: createElement("div", null, "Profile"),
+ update: null,
+ eligibleMachines: [],
+ onDismiss,
+ onRequestUpdate: vi.fn(),
+ onInitialFocus,
+ }
+ const renderer = render(createElement(UserBarExtensionSlot, props))
+ renderer.rerender(createElement(UserBarExtensionSlot, {
+ ...props, interactive: false, focusOnOpen: true,
+ }))
+ await act(async () => {
+ document.body.click()
+ document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }))
+ })
+ expect(onDismiss).not.toHaveBeenCalled()
+ expect(onInitialFocus).not.toHaveBeenCalled()
+ expect(renderer.getByText("Profile")).toBeInTheDocument()
+ })
+
it("renders only the active Inbox occupant in the bounded joined surface", () => {
const renderer = render(createElement(UserBarExtensionSlot, {
active: "inbox",
@@ -184,6 +209,7 @@ describe("UserBarExtensionSlot", () => {
})
it("moves focus into the dialog only for an explicit open request", () => {
+ const focus = vi.spyOn(HTMLElement.prototype, "focus")
const onInitialFocus = vi.fn()
const renderer = render(createElement(UserBarExtensionSlot, {
active: "inbox",
@@ -200,5 +226,7 @@ describe("UserBarExtensionSlot", () => {
expect(slot).toHaveAttribute("tabindex", "-1")
expect(slot).toHaveFocus()
expect(onInitialFocus).toHaveBeenCalledOnce()
+ expect(focus).toHaveBeenCalledWith({ preventScroll: true })
+ focus.mockRestore()
})
})
diff --git a/src/web/src/components/community/shell/user-bar-extension-slot.tsx b/src/web/src/components/community/shell/user-bar-extension-slot.tsx
index 22c87668f..183339a95 100644
--- a/src/web/src/components/community/shell/user-bar-extension-slot.tsx
+++ b/src/web/src/components/community/shell/user-bar-extension-slot.tsx
@@ -33,6 +33,8 @@ type Props = {
onDismiss: () => void
onDismissOutside?: () => void
onRequestUpdate: () => void
+ interactive?: boolean
+ animate?: boolean
focusOnOpen?: boolean
onInitialFocus?: () => void
}
@@ -46,12 +48,15 @@ export function UserBarExtensionSlot({
onDismiss,
onDismissOutside = onDismiss,
onRequestUpdate,
+ interactive = true,
+ animate = true,
focusOnOpen = false,
onInitialFocus,
}: Props) {
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
+ if (!interactive) return
const onKeyDown = (event: KeyboardEvent) => {
if (event.key !== "Escape") return
event.preventDefault()
@@ -70,13 +75,13 @@ export function UserBarExtensionSlot({
document.removeEventListener("keydown", onKeyDown)
document.removeEventListener("click", onClick)
}
- }, [onDismiss, onDismissOutside])
+ }, [interactive, onDismiss, onDismissOutside])
useEffect(() => {
- if (!focusOnOpen) return
- ref.current?.focus()
+ if (!interactive || !focusOnOpen) return
+ ref.current?.focus({ preventScroll: true })
onInitialFocus?.()
- }, [active, focusOnOpen, onInitialFocus])
+ }, [active, interactive, focusOnOpen, onInitialFocus])
const title = active === "inbox"
? "Inbox"
@@ -96,7 +101,7 @@ export function UserBarExtensionSlot({
tabIndex={-1}
className={cn(
"relative min-h-0 origin-bottom overflow-hidden rounded-t-xl border-x border-t border-border/40 bg-popover text-popover-foreground shadow-(--e2) [clip-path:inset(-2rem_-2rem_0)]",
- "motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-1 motion-safe:duration-150",
+ animate && "motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-1 motion-safe:duration-150",
active === "inbox" && "flex flex-col",
)}
style={{
diff --git a/src/web/src/components/community/shell/user-bar.interaction.dom.test.ts b/src/web/src/components/community/shell/user-bar.interaction.dom.test.ts
index 29ce3a571..083202504 100644
--- a/src/web/src/components/community/shell/user-bar.interaction.dom.test.ts
+++ b/src/web/src/components/community/shell/user-bar.interaction.dom.test.ts
@@ -1,13 +1,9 @@
-import { createElement, type PropsWithChildren } from "react"
+import { createElement } from "react"
import { describe, expect, it, vi } from "vitest"
import { render, screen, setupUser } from "@/test/react-dom-harness"
import { UserBar } from "./user-bar"
import { tid } from "@/lib/community/testids"
-vi.mock("./community-inbox-surface", () => ({
- CommunityInboxSurface: ({ children }: PropsWithChildren) =>
- createElement("div", { "data-testid": "inbox-surface" }, children),
-}))
vi.mock("../avatar", () => ({
Avatar: () => createElement("span", { "data-testid": "user-avatar" }),
}))
@@ -31,6 +27,37 @@ function renderBar() {
}
describe("UserBar Inbox switching", () => {
+ it.each(["mobile", "desktop"] as const)("renders the real %s extension through its intended motion surface", (breakpoint) => {
+ const inbox = createElement("button", null, "Inbox item")
+ const renderer = render(createElement(UserBar, {
+ breakpoint,
+ user: { id: "u1", name: "User", avatar: "U" },
+ inbox,
+ hasUnread: false,
+ inboxOpen: true,
+ extension: {
+ active: "inbox",
+ inbox,
+ profile: null,
+ update: null,
+ updateBadgePhase: null,
+ eligibleMachines: [],
+ onOpenUpdate: vi.fn(),
+ onRequestUpdate: vi.fn(),
+ onDismiss: vi.fn(),
+ },
+ }))
+ const dialog = renderer.getByRole("dialog", { name: "Inbox" })
+ expect(renderer.getAllByRole("button", { name: "Inbox item" })).toHaveLength(1)
+ if (breakpoint === "mobile") {
+ expect(dialog.closest(".community-user-bar-drawer")).not.toBeNull()
+ expect(dialog.className).not.toContain("fade-in")
+ } else {
+ expect(dialog.closest(".community-user-bar-drawer")).toBeNull()
+ expect(dialog.className).toContain("fade-in")
+ }
+ })
+
it.each(["avatar", "name"])("closes before the %s profile action exactly once", async (kind) => {
const user = setupUser()
const { order, onInboxOpenChange, onOpenProfile } = renderBar()
diff --git a/src/web/src/components/community/shell/user-bar.tsx b/src/web/src/components/community/shell/user-bar.tsx
index f19227d22..dcc8dd1a2 100644
--- a/src/web/src/components/community/shell/user-bar.tsx
+++ b/src/web/src/components/community/shell/user-bar.tsx
@@ -16,7 +16,7 @@ import type { Presence } from "@/lib/community/models/people"
import type { Breakpoint } from "@/hooks/use-mobile"
import { tid } from "@/lib/community/testids"
import { cn } from "@/lib/utils"
-import { CommunityInboxSurface } from "./community-inbox-surface"
+import { UserBarExtensionDrawer } from "./user-bar-extension-drawer"
import { UserBarExtensionSlot } from "./user-bar-extension-slot"
import type {
UserBarExtensionKind,
@@ -47,16 +47,13 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,
onInboxOpenChange?: (open: boolean) => void
extension?: UserBarExtension
}) {
- const inboxAnchorRef = useRef<HTMLDivElement>(null)
const profileTriggerRef = useRef<HTMLButtonElement>(null)
const profileNameTriggerRef = useRef<HTMLButtonElement>(null)
const lastProfileTriggerRef = useRef<HTMLButtonElement | null>(null)
const inboxTriggerRef = useRef<HTMLButtonElement>(null)
const updateBadgeRef = useRef<HTMLButtonElement>(null)
const [pendingExtensionFocus, setPendingExtensionFocus] = useState<UserBarExtensionKind>("none")
- const suppressInboxFocusReturnRef = useRef(false)
const closeInboxForAction = () => {
- suppressInboxFocusReturnRef.current = true
if (inboxOpen) onInboxOpenChange?.(false)
}
const dismissExtensionWithFocus = () => {
@@ -71,31 +68,33 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,
else updateBadgeRef.current?.focus()
})
}
+ const extensionContent = extension && extension.active !== "none" ? (
+ <UserBarExtensionSlot
+ active={extension.active}
+ inbox={extension.inbox}
+ profile={extension.profile}
+ update={extension.update}
+ eligibleMachines={extension.eligibleMachines}
+ onDismiss={dismissExtensionWithFocus}
+ onDismissOutside={extension.onDismiss}
+ onRequestUpdate={extension.onRequestUpdate}
+ focusOnOpen={pendingExtensionFocus === extension.active}
+ onInitialFocus={() => {
+ if (pendingExtensionFocus === extension.active) {
+ setPendingExtensionFocus("none")
+ }
+ }}
+ />
+ ) : null
return (
<div
data-testid={tid.userBar}
className="w-full min-w-0 max-w-full shrink-0 overflow-hidden pl-[max(0.75rem,var(--app-safe-area-left))] pr-[max(0.75rem,var(--app-safe-area-right))] pb-[calc(0.75rem+var(--app-safe-area-bottom))] pt-0 sm:px-3 sm:pb-3"
>
- {extension && extension.active !== "none" && (
- <UserBarExtensionSlot
- active={extension.active}
- inbox={extension.inbox}
- profile={extension.profile}
- update={extension.update}
- eligibleMachines={extension.eligibleMachines}
- onDismiss={dismissExtensionWithFocus}
- onDismissOutside={extension.onDismiss}
- onRequestUpdate={extension.onRequestUpdate}
- focusOnOpen={pendingExtensionFocus === extension.active}
- onInitialFocus={() => {
- if (pendingExtensionFocus === extension.active) {
- setPendingExtensionFocus("none")
- }
- }}
- />
- )}
+ {breakpoint === "mobile"
+ ? <UserBarExtensionDrawer>{extensionContent}</UserBarExtensionDrawer>
+ : extensionContent}
<div
- ref={inboxAnchorRef}
data-slot="community-user-bar-base"
className={cn(
"flex h-12 items-center gap-3 border border-border/40 bg-muted px-4",
@@ -113,8 +112,6 @@ export function UserBar({ breakpoint, user, onOpenProfile, onEditProfile, inbox,
hasUnread={hasUnread}
inboxOpen={inboxOpen}
onInboxOpenChange={onInboxOpenChange}
- inboxAnchorRef={inboxAnchorRef}
- suppressInboxFocusReturnRef={suppressInboxFocusReturnRef}
closeInboxForAction={closeInboxForAction}
profileTriggerRef={profileTriggerRef}
profileNameTriggerRef={profileNameTriggerRef}
@@ -146,7 +143,7 @@ export function UserBarSkeleton() {
)
}
-function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnread, inboxOpen, onInboxOpenChange, inboxAnchorRef, suppressInboxFocusReturnRef, closeInboxForAction, profileTriggerRef, profileNameTriggerRef, lastProfileTriggerRef, inboxTriggerRef, updateBadgeRef, onRequestExtensionFocus, extension }: {
+function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnread, inboxOpen, onInboxOpenChange, closeInboxForAction, profileTriggerRef, profileNameTriggerRef, lastProfileTriggerRef, inboxTriggerRef, updateBadgeRef, onRequestExtensionFocus, extension }: {
breakpoint: Breakpoint
user: { id: string; name: string; avatar: string; presence?: Presence }
onOpenProfile?: OpenProfile
@@ -155,8 +152,6 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
hasUnread: boolean
inboxOpen?: boolean
onInboxOpenChange?: (open: boolean) => void
- inboxAnchorRef: RefObject<HTMLDivElement | null>
- suppressInboxFocusReturnRef: MutableRefObject<boolean>
closeInboxForAction: () => void
profileTriggerRef: RefObject<HTMLButtonElement | null>
profileNameTriggerRef: RefObject<HTMLButtonElement | null>
@@ -218,7 +213,7 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
)} />
</button>
)}
- {inbox && extension ? (
+ {inbox ? (
<button
ref={inboxTriggerRef}
type="button"
@@ -232,7 +227,7 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
aria-label={mobile ? (inboxOpen ? "Close Inbox" : "Open Inbox") : "Inbox"}
aria-expanded={inboxOpen}
aria-pressed={mobile ? inboxOpen : undefined}
- aria-controls={inboxOpen ? "community-user-bar-extension" : undefined}
+ aria-controls={inboxOpen && extension ? "community-user-bar-extension" : undefined}
onClick={() => {
if (!inboxOpen) onRequestExtensionFocus("inbox")
onInboxOpenChange?.(!inboxOpen)
@@ -243,17 +238,6 @@ function Inner({ breakpoint, user, onOpenProfile, onEditProfile, inbox, hasUnrea
{hasUnread && <span className="absolute -right-1 -top-1 size-2 rounded-full bg-primary" />}
</span>
</button>
- ) : inbox ? (
- <CommunityInboxSurface
- breakpoint={breakpoint}
- open={inboxOpen}
- onOpenChange={onInboxOpenChange}
- hasUnread={hasUnread}
- anchorRef={inboxAnchorRef}
- suppressFocusReturnRef={suppressInboxFocusReturnRef}
- >
- {inbox}
- </CommunityInboxSurface>
) : null}
<button
onClick={() => {
diff --git a/src/web/src/test/architecture/community-unread-projection-owner-contract.test.ts b/src/web/src/test/architecture/community-unread-projection-owner-contract.test.ts
index 7489069d4..bc96ce7be 100644
--- a/src/web/src/test/architecture/community-unread-projection-owner-contract.test.ts
+++ b/src/web/src/test/architecture/community-unread-projection-owner-contract.test.ts
@@ -36,7 +36,7 @@ describe("community unread projection owner contract", () => {
it("keeps dot components presentation-only", () => {
const consumers = [
"src/web/src/components/community/shell/community-inbox-popover.tsx",
- "src/web/src/components/community/shell/community-inbox-surface.tsx",
+ "src/web/src/components/community/shell/user-bar.tsx",
"src/web/src/components/community/shell/rail-folder.tsx",
"src/web/src/components/community/shell/sortable-server.tsx",
"src/web/src/components/community/channels/channel-sidebar.tsx",
@@ -65,7 +65,7 @@ describe("community unread projection owner contract", () => {
expect(popover).not.toMatch(/hasProjectedMentions\s*\?\?/)
const surface = source(
- "src/web/src/components/community/shell/community-inbox-surface.tsx",
+ "src/web/src/components/community/shell/user-bar.tsx",
)
expect(surface).toContain("hasUnread: boolean")
})