Skip to content

fix(hub-ui): keep dock safe-area variables off <html> - #483

Merged
antfu merged 3 commits into
devframes:mainfrom
omridevk:fix/dock-safe-area-on-anchor
Nov 10, 2026
Merged

antfu merged 3 commits into
devframes:mainfrom
omridevk:fix/dock-safe-area-on-anchor

Conversation

@omridevk

@omridevk omridevk commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

fix #482

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

@vercel

vercel Bot commented Nov 4, 2026

Copy link
Copy Markdown

@omridevk is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

👁️‍🗨️ Review this pull request with grouped, summarized diffs at:
👉 https://pulls.review/gh/devframes/devframe/483?from=github-actions[bot]

raw result

💭 analyzed by vercel-ai-gateway/anthropic/claude-sonnet-5
🕰️ 2026-11-10 06:05 UTC
🔗 head ca46ae8
🤖 automated by pulls.review

{
  "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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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:

  1. Port back the fix to VueUse
  2. Remove the safeArea usage all together? probably not
  3. Close PR and accept the warning and have the users manually import the Dock

@omridevk
omridevk marked this pull request as ready for review November 4, 2026 20:02
Copilot AI balanced review requested due to automatic review settings November 4, 2026 20:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 useSafeArea utility 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

Comment on lines +20 to +23
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>
@omridevk
omridevk force-pushed the fix/dock-safe-area-on-anchor branch from 0fb86d4 to 47ca623 Compare November 4, 2026 20:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the element-based safe-area change.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 4, 2026 20:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the dock’s safe-area hook update.

1 open issue

Review effort: Balanced

antfubot and others added 2 commits November 10, 2026 05:50
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>
@antfu
antfu merged commit b58a2f4 into devframes:main Nov 10, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dock causes a React hydration mismatch on <html> in SSR apps

4 participants