Skip to content

fix(share): default comment panel closed on mobile viewports#177

Open
rubenxyz wants to merge 2 commits into
Techiebutler:mainfrom
rubenxyz:fix/mobile-share-sidebar-default
Open

fix(share): default comment panel closed on mobile viewports#177
rubenxyz wants to merge 2 commits into
Techiebutler:mainfrom
rubenxyz:fix/mobile-share-sidebar-default

Conversation

@rubenxyz

Copy link
Copy Markdown
Contributor

Summary

  • The share page sidebar (comment panel) was hardcoded to useState(true), causing it to be open by default on all screen sizes
  • On mobile devices, this means users see the comment pane instead of the video on first load
  • Changed to useState(typeof window !== 'undefined' && window.matchMedia('(min-width: 768px)').matches) so the panel defaults to closed on viewports < 768px

Why

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.

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 ravirajsinh45 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.

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 FolderShareViewerShareReviewInner, 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.
@rubenxyz

Copy link
Copy Markdown
Contributor Author

Addressed all three items:

  1. Folder-share-viewer parity — applied the same matchMedia default to FolderShareViewer/ShareReviewInnern at folder-share-viewer.tsx:801. Folder/project shares now also default to closed on mobile viewports.

  2. CHANGELOG — added entry under [Unreleased] ### Fixed.

  3. Lazy initializer — the single-asset path in ShareViewer also now uses React.useState(() => ...) to avoid re-evaluating matchMedia on every render.

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.

2 participants