Repository navigation
fix(hub-ui): keep dock safe-area variables off <html> - #483
Conversation
|
@omridevk is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"headSha": "ca46ae820672aa281bd72249bdd729611252b661",
"result": {
"overallSummary": "Fixes a bug where the Dock component's safe-area handling (via VueUse's `useScreenSafeArea`) wrote CSS variables onto `<html>`, breaking SSR hydration. A new `useSafeArea` composable reads safe-area insets from a scoped element instead, backed by CSS custom properties, and returns numeric values directly.",
"groups": [
{
"key": "dock-safe-area",
"label": "Dock safe-area fix",
"summary": "Replaces VueUse's `useScreenSafeArea` (which writes CSS variables onto `<html>` and breaks SSR hydration) with a custom `useSafeArea` composable that reads safe-area inset CSS variables from a specific element instead, and updates the Dock component to use it.",
"category": "ui",
"filePaths": [
"packages/hub-ui/src/client/components/dock/Dock.vue",
"packages/hub-ui/src/client/utils/useSafeArea.ts",
"packages/hub-ui/src/client/style.css"
],
"critical": false,
"fileNotes": [
{
"path": "packages/hub-ui/src/client/utils/useSafeArea.ts",
"text": "New composable reads `--devframes-safe-area-*` custom properties from a given target element (not `<html>`) to avoid the SSR hydration issue in the linked bug."
},
{
"path": "packages/hub-ui/src/client/style.css",
"text": "Defines the `--devframes-safe-area-*` custom properties from `env(safe-area-inset-*)` that `useSafeArea` reads back."
},
{
"path": "packages/hub-ui/src/client/components/dock/Dock.vue",
"text": "Switches from `useScreenSafeArea` to the new `useSafeArea(anchorEl)`, now returning numeric insets directly instead of string values requiring manual parsing."
}
]
}
],
"schemaVersion": 1,
"source": "llm",
"generatedAt": "2026-11-10T06:05:53.843Z",
"model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
"locale": "en"
}
} |
|
|
||
| /** | ||
| * Ported from VueUse's `useScreenSafeArea` for now: it always sets its CSS variables on | ||
| * `<html>` and has no option for a custom element, which breaks hydration on SSR hosts. |
There was a problem hiding this comment.
@antfu I wasn't sure about this part, so I added this "port" to suggest whether this addition should be added to VueUse, didn't want to make too many decisions, do let me know if this is even a good direction, or:
- Port back the fix to VueUse
- Remove the safeArea usage all together? probably not
- Close PR and accept the warning and have the users manually import the Dock
There was a problem hiding this comment.
🟡 Changes recommended
Safe-area values retain their px units and are converted to zero by toNumber(), allowing the dock and its panel to overlap a notch or home indicator.
1 open issue
What changed in this PR
This PR addresses #482 by replacing the dock’s safe-area reader so it no longer adds inline styles to <html>, avoiding React SSR hydration mismatches.
Changes:
- Add a target-based
useSafeAreautility that reads insets on mount and resize. - Define safe-area CSS variables in the hub UI stylesheet.
- Connect the dock’s anchor element to the new utility.
| File | Description |
|---|---|
packages/hub-ui/src/client/utils/useSafeArea.ts |
Adds element-scoped safe-area measurement. |
packages/hub-ui/src/client/style.css |
Defines four safe-area inset variables. |
packages/hub-ui/src/client/components/dock/Dock.vue |
Replaces useScreenSafeArea with the anchor-based utility. |
Review effort: Balanced
| top.value = style.getPropertyValue('--devframes-safe-area-top') | ||
| right.value = style.getPropertyValue('--devframes-safe-area-right') | ||
| bottom.value = style.getPropertyValue('--devframes-safe-area-bottom') | ||
| left.value = style.getPropertyValue('--devframes-safe-area-left') |
useScreenSafeArea sets its CSS variables on <html>, which React SSR hosts hydrate themselves, so loading the dock logs a hydration mismatch. Port it as useSafeArea(target): the variables live in the dock stylesheet :host and are read back from the dock anchor. Also parse the insets with parseFloat, since values like "34px" made the unary plus return NaN, so insets were 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0fb86d4 to
47ca623
Compare
useSafeArea now parses the px values itself and returns one DockMargins ref. The Dock passes it straight to resolveViewportMargins, so the toNumber helper is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

fix #482
(Disclaimer, code was written with Claude, but was meticulously reviewed by a human being or so I claim to be :P )