Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(web): correct mobile popover and nav geometry

Gus654f9dbc3ba8
diff --git a/src/web/src/components/community/shell/shell-frame-view.test.ts b/src/web/src/components/community/shell/shell-frame-view.test.ts
index 3819ba08e..dc14168b1 100644
--- a/src/web/src/components/community/shell/shell-frame-view.test.ts
+++ b/src/web/src/components/community/shell/shell-frame-view.test.ts
@@ -139,6 +139,10 @@ describe("ShellFrameView", () => {
})
expect(renderer.root.findAllByType("server-rail")).toHaveLength(1)
expect(renderer.root.findAllByType("user-bar")).toHaveLength(1)
+ const mobileSurface = renderer.root.findByType("app-surface")
+ expect(mobileSurface.props.className).toContain("rounded-tl-xl")
+ expect(mobileSurface.props.className).toContain("border-l")
+ expect(mobileSurface.props.className).toContain("border-t")
expect(renderer.root.findAllByType("main-content")).toHaveLength(0)
expect(renderer.root.findAllByType("shell-overlays")).toHaveLength(1)
expect("profileStatusSeeds" in renderer.root.findByType("shell-overlays").props).toBe(false)
@@ -158,6 +162,7 @@ describe("ShellFrameView", () => {
})
expect(renderer.root.findAllByType("server-rail")).toHaveLength(0)
expect(renderer.root.findAllByType("user-bar")).toHaveLength(0)
+ expect(renderer.root.findAllByType("app-surface")).toHaveLength(0)
expect(renderer.root.findAllByType("main-content")).toHaveLength(1)
expect(renderer.root.findAllByType("shell-overlays")).toHaveLength(1)
})
diff --git a/src/web/src/components/community/shell/shell-frame-view.tsx b/src/web/src/components/community/shell/shell-frame-view.tsx
index ee3972f42..a77aeb11b 100644
--- a/src/web/src/components/community/shell/shell-frame-view.tsx
+++ b/src/web/src/components/community/shell/shell-frame-view.tsx
@@ -31,6 +31,8 @@ type Props = Pick<ShellFrameProps, "sidebar" | "children" | "extraDialogs"> & {
inbox: ReturnType<typeof useShellInboxController>
}
+const SHELL_SURFACE_CLASS = "rounded-tl-xl rounded-tr-none rounded-br-none rounded-bl-none ring-0 border-l border-t border-border/40 shadow-none"
+
export function ShellFrameView({
breakpoint,
mobileZone,
@@ -67,7 +69,7 @@ export function ShellFrameView({
<Shell onNavigationIntent={cancelPendingNavigation}>
<ServerRail {...rail.railProps} bottomInset={60} />
<div className="relative flex-1 flex flex-col min-w-0 pt-2">
- <AppSurface className="rounded-tl-xl rounded-tr-none rounded-br-none rounded-bl-none ring-0 border-l border-t border-border/40 shadow-none">
+ <AppSurface className={SHELL_SURFACE_CLASS}>
<ResizablePanelGroup
id="community-shell"
orientation="horizontal"
@@ -132,19 +134,23 @@ export function ShellFrameView({
{mobileZone === "nav" && (
<>
<ServerRail {...rail.railProps} bottomInset={60} />
- <div className="flex min-h-0 min-w-0 flex-1 flex-col bg-sidebar">
- <div className="flex min-h-0 min-w-0 flex-1">
- {sidebar({ noHeader: false })}
- </div>
- <UserBar
- user={user}
- onOpenProfile={profile.openProfile}
- onEditProfile={profile.openUserSettings}
- inbox={inboxElement}
- hasUnread={inbox.hasUnread}
- inboxOpen={inbox.open}
- onInboxOpenChange={inbox.onOpenChange}
- />
+ <div className="relative flex min-h-0 min-w-0 flex-1 flex-col pt-2">
+ <AppSurface className={SHELL_SURFACE_CLASS}>
+ <div className="flex min-h-0 min-w-0 flex-1 flex-col bg-sidebar">
+ <div className="flex min-h-0 min-w-0 flex-1">
+ {sidebar({ noHeader: false })}
+ </div>
+ <UserBar
+ user={user}
+ onOpenProfile={profile.openProfile}
+ onEditProfile={profile.openUserSettings}
+ inbox={inboxElement}
+ hasUnread={inbox.hasUnread}
+ inboxOpen={inbox.open}
+ onInboxOpenChange={inbox.onOpenChange}
+ />
+ </div>
+ </AppSurface>
</div>
</>
)}
diff --git a/src/web/src/hooks/use-anchored-popover.test.ts b/src/web/src/hooks/use-anchored-popover.test.ts
index 4b492446f..12dc87e85 100644
--- a/src/web/src/hooks/use-anchored-popover.test.ts
+++ b/src/web/src/hooks/use-anchored-popover.test.ts
@@ -14,17 +14,20 @@ function rect(top: number, left: number, height = 16): AnchorRect {
}
describe("anchoredPopoverStyle", () => {
- it("anchors above the caret when the visual viewport has room", () => {
+ it("converts visual coordinates to layout-fixed coordinates exactly once", () => {
const style = anchoredPopoverStyle(rect(400, 40), VIEWPORT, 256, 240)
- expect(style.top).toBe(396)
- expect(style.left).toBe(40)
+ expect(style.top).toBe(496)
+ expect(style.left).toBe(60)
+ expect(Number(style.top) - VIEWPORT.top).toBe(396)
+ expect(Number(style.left) - VIEWPORT.left).toBe(40)
expect(style.transform).toBe("translateY(-100%)")
expect(style["--anchored-popover-max-height"]).toBe("240px")
})
it("flips below a caret near the visual viewport top", () => {
- const style = anchoredPopoverStyle(rect(120, 40), VIEWPORT, 256, 240)
+ const style = anchoredPopoverStyle(rect(20, 40), VIEWPORT, 256, 240)
expect(style.top).toBe(140)
+ expect(Number(style.top) - VIEWPORT.top).toBe(40)
expect(style.transform).toBeUndefined()
})
@@ -35,10 +38,22 @@ describe("anchoredPopoverStyle", () => {
it("uses the roomier side and reduces list height when neither side fully fits", () => {
const shortViewport = { top: 100, left: 0, width: 320, height: 220 }
- const style = anchoredPopoverStyle(rect(180, 20), shortViewport, 256, 240)
+ const style = anchoredPopoverStyle(rect(80, 20), shortViewport, 256, 240)
expect(style.transform).toBeUndefined()
expect(style["--anchored-popover-max-height"]).toBe("102px")
})
+
+ it("keeps zero-offset desktop geometry unchanged", () => {
+ const style = anchoredPopoverStyle(
+ rect(400, 40),
+ { top: 0, left: 0, width: 320, height: 500 },
+ 256,
+ 240,
+ )
+ expect(style.top).toBe(396)
+ expect(style.left).toBe(40)
+ expect(style.transform).toBe("translateY(-100%)")
+ })
})
describe("visual viewport refresh signals", () => {
diff --git a/src/web/src/hooks/use-anchored-popover.ts b/src/web/src/hooks/use-anchored-popover.ts
index b2b165a0a..817d73bb6 100644
--- a/src/web/src/hooks/use-anchored-popover.ts
+++ b/src/web/src/hooks/use-anchored-popover.ts
@@ -144,14 +144,23 @@ export function anchoredPopoverStyle(
popupWidth: number,
popupMaxHeight: number,
): AnchoredPopoverStyle {
- const viewportRight = viewport.left + viewport.width
- const viewportBottom = viewport.top + viewport.height
- const minLeft = viewport.left + VIEWPORT_MARGIN
- const maxLeft = Math.max(minLeft, viewportRight - popupWidth - VIEWPORT_MARGIN)
- const left = Math.min(Math.max(rect.left, minLeft), maxLeft)
-
- const spaceAbove = rect.top - viewport.top
- const spaceBelow = viewportBottom - rect.bottom
+ // `getBoundingClientRect()` / TipTap's `clientRect()` report coordinates in
+ // the visual viewport, while iOS lays out `position: fixed` descendants
+ // against the layout viewport. Convert only the final CSS coordinates back
+ // to layout space; all fit calculations stay in visual-viewport space.
+ const minVisibleLeft = VIEWPORT_MARGIN
+ const maxVisibleLeft = Math.max(
+ minVisibleLeft,
+ viewport.width - popupWidth - VIEWPORT_MARGIN,
+ )
+ const visibleLeft = Math.min(
+ Math.max(rect.left, minVisibleLeft),
+ maxVisibleLeft,
+ )
+ const left = viewport.left + visibleLeft
+
+ const spaceAbove = rect.top
+ const spaceBelow = viewport.height - rect.bottom
const fullHeight = popupMaxHeight + POPOVER_CHROME_HEIGHT + POPOVER_GAP + VIEWPORT_MARGIN
const placeBelow = spaceAbove < fullHeight
&& (spaceBelow >= fullHeight || spaceBelow > spaceAbove)
@@ -167,10 +176,10 @@ export function anchoredPopoverStyle(
}
return placeBelow
- ? { ...common, top: rect.bottom + POPOVER_GAP }
+ ? { ...common, top: viewport.top + rect.bottom + POPOVER_GAP }
: {
...common,
- top: rect.top - POPOVER_GAP,
+ top: viewport.top + rect.top - POPOVER_GAP,
transform: "translateY(-100%)",
}
}