Add useVisualViewportSize hook#16
Merged
Merged
Conversation
4 tasks
There was a problem hiding this comment.
Pull request overview
This PR adds a new useVisualViewportSize hook to expose window.visualViewport.height and window.visualViewport.offsetTop, along with per-hook documentation and an entry in the root Hooks Reference table.
Changes:
- Added
useVisualViewportSizehook implemented viauseSyncExternalStore. - Added hook documentation (
src/useVisualViewportSize/README.md) including usage example. - Registered the new hook in the root
README.mdHooks Reference table.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/useVisualViewportSize/index.ts | Implements the new hook using useSyncExternalStore and window.visualViewport. |
| src/useVisualViewportSize/README.md | Documents the hook API, SSR/unavailable behavior, and provides an example. |
| README.md | Adds useVisualViewportSize to the hooks reference list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
gabmontes
previously approved these changes
May 14, 2026
Contributor
|
@gndelia no version bump? |
Contributor
Author
|
gndelia
added a commit
to vetro-protocol/vetro-monorepo
that referenced
this pull request
May 14, 2026
The hook exposes offsetTop reactively but only subscribed to resize. Per the VisualViewport spec, offsetTop changes fire the scroll event (e.g., pinch-zoom panning after the keyboard is open), so resize-only subscription returns stale offsetTop in those cases. Mirror this in hemilabs/react-hooks#16 so the upstream stays the source of truth. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
gabmontes
approved these changes
May 14, 2026
ArturDolzan
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Adds a new
useVisualViewportSizehook that returns the currentVisualViewportheight and top offset, useful for handling on-screen keyboards on mobile and pinch-zoom layout adjustments. Also adds the hook'sREADME.mdand registers it in the root README's Hooks Reference table.Note: no version bump in this PR — a few more changes are coming and they will all be released together.
Screenshots
N/A — no UI artifacts; pure hook addition.
Related issue(s)
N/A
Checklist