Skip to content

fix(media): Tags panel on viewports wider than 1920px (#1587)#1592

Merged
stipsan merged 1 commit into
mainfrom
cursor/fix-media-tags-breakpoint-1760
Jul 16, 2026
Merged

fix(media): Tags panel on viewports wider than 1920px (#1587)#1592
stipsan merged 1 commit into
mainfrom
cursor/fix-media-tags-breakpoint-1760

Conversation

@stipsan

@stipsan stipsan commented Jul 15, 2026

Copy link
Copy Markdown
Member

Fixes #1587

Problem

On viewports wider than 1920 CSS px, the Tags panel toggle appeared dead. The home-rolled useBreakpointIndex built max-width queries from theme container widths and used findIndex, which returns -1 when nothing matches. Items then treated -1 <= 1 as a small screen and immediately force-hid the panel.

The toolbar toggle stayed visible because Controls already uses @sanity/ui's responsive display / useMediaIndex, which handle wide viewports correctly.

Fix

  • Replace useBreakpointIndex in Items with useMediaIndex from @sanity/ui (same hook already used in Controls, TableRowAsset, etc.)
  • Remove the unused custom hook

useMediaIndex includes a min-width catch-all for the widest bucket, so ultra-wide viewports get the largest index instead of -1, and it uses theme media breakpoints consistent with the rest of the plugin.

Verification

  • pnpm --filter sanity-plugin-media build — pass
  • pnpm --filter sanity-plugin-media exec vitest run — 149 tests pass
  • pnpm knip — pass
  • pnpm lint -- plugins/sanity-plugin-media/src/components/Items/index.tsx — pass
Open in Web Open in Cursor 

The home-rolled useBreakpointIndex returned -1 above 1920px, which
force-hid the Tags panel. Switch Items to @sanity/ui's useMediaIndex,
which includes a min-width catch-all and matches Controls breakpoints.
@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 84a2a13

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sanity-plugin-media Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plugins-studio Ready Ready Preview, Comment Jul 15, 2026 9:20pm

Request Review

@stipsan stipsan added the 🤖 bot label Jul 15, 2026 — with Cursor
@stipsan
stipsan marked this pull request as ready for review July 15, 2026 21:26
Copilot AI review requested due to automatic review settings July 15, 2026 21:26
@stipsan
stipsan requested a review from a team as a code owner July 15, 2026 21:26
@stipsan
stipsan requested review from pedrobonamin and removed request for a team July 15, 2026 21:26
@stipsan
stipsan enabled auto-merge (squash) July 15, 2026 21:26

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.

Pull request overview

Fixes an ultra-wide viewport bug in sanity-plugin-media where the Tags panel toggle could never open on viewports wider than 1920px due to a custom breakpoint hook returning -1.

Changes:

  • Replaced the custom useBreakpointIndex logic in Items with @sanity/ui’s useMediaIndex to correctly handle wide viewports.
  • Removed the unused home-rolled useBreakpointIndex hook implementation.
  • Added a patch changeset for sanity-plugin-media documenting the fix.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
plugins/sanity-plugin-media/src/components/Items/index.tsx Switches responsive logic to useMediaIndex so the Tags panel is not force-hidden on ultra-wide viewports.
plugins/sanity-plugin-media/src/hooks/useBreakpointIndex.ts Removes the now-unused custom breakpoint hook that could return -1 on very wide screens.
.changeset/media-tags-panel-wide-viewport.md Adds a patch changeset describing the Tags panel fix for wide viewports.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pedrobonamin pedrobonamin 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.

Nice fix, thank you!

@stipsan
stipsan merged commit 0cad29a into main Jul 16, 2026
15 checks passed
@stipsan
stipsan deleted the cursor/fix-media-tags-breakpoint-1760 branch July 16, 2026 07:52
@squiggler-app squiggler-app Bot mentioned this pull request Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[sanity-plugin-media] Tags panel cannot be opened on viewports wider than 1920px (useBreakpointIndex returns -1)

4 participants