fix(share): default comment panel closed on mobile viewports#177
fix(share): default comment panel closed on mobile viewports#177rubenxyz wants to merge 2 commits into
Conversation
The sidebar (comment panel) was hardcoded to open on all screen sizes, causing mobile users to see the comment pane instead of the video on first load. Now defaults to closed below 768px.
ravirajsinh45
left a comment
There was a problem hiding this comment.
Thanks @rubenxyz — diagnosis is right and the single-asset share path is fixed correctly. Two things before we merge:
1. The folder/project share path has the same bug. Share links have two viewer components: ShareViewer (the one you patched) handles single-asset shares, but folder and project shares route to FolderShareViewer → ShareReviewInner, which has its own copy at apps/web/components/share/folder-share-viewer.tsx:801:
const [sidebarOpen, setSidebarOpen] = React.useState(true)with the same w-[360px] ... shrink-0 panel at line 924. Opening a folder share on a phone and tapping an asset reproduces exactly the bug you're fixing. Could you apply the same default there?
2. CHANGELOG entry. We track user-facing changes in CHANGELOG.md under ## [Unreleased]. Could you add this to the existing ### Fixed list?
- **Public share links open on the media, not the comment panel, on phones** — the shared asset viewer's comment panel defaulted to open at every screen size, so opening a video share link on a phone showed the comment pane first with the video pushed to a sliver off-screen. The panel now starts closed below the `md` breakpoint (768px) and open above it; it can still be toggled either way.That rule currently only lives in AGENTS.md, not CONTRIBUTING.md or the PR template — our miss, tracked in #189.
Nit, optional: make the initializer lazy so matchMedia isn't re-evaluated on every render — React.useState(() => typeof window !== 'undefined' && …).
Checked and fine: no hydration risk (ShareViewer only mounts after the client-side share fetch resolves — stage starts at loading), 768px matches Tailwind's default md, CI green.
Two things we'll handle separately, not for this PR: the panel is a fixed w-[360px] shrink-0, so opening it on a phone still squeezes the player (#187); and window.matchMedia isn't stubbed in our vitest/jsdom setup, so we'll add that before this area can get a regression test (#188).
…NGELOG - FolderShareViewer/ShareReviewInner had its own hardcoded useState(true) for the comment panel, causing the same mobile UX issue on folder/project shares. Defaults to closed below 768px now. - Added CHANGELOG entry under [Unreleased] ### Fixed.
|
Addressed all three items:
|
Summary
useState(true), causing it to be open by default on all screen sizesuseState(typeof window !== 'undefined' && window.matchMedia('(min-width: 768px)').matches)so the panel defaults to closed on viewports < 768pxWhy
When opening a video share link on mobile (Android/iOS), the first thing visible is the comment panel pulled out from the right, not the video itself. The video is pushed off-screen or to a tiny sliver. This fix makes the panel default to closed on mobile, matching expected behavior.