Skip to content

fix(ui): keep formula editor within the viewport on small screens - #256

Merged
Sall25 merged 1 commit into
Sall25:mainfrom
Furox-Art:fix/formula-editor-mobile-overflow
Oct 12, 2026
Merged

Sall25 merged 1 commit into
Sall25:mainfrom
Furox-Art:fix/formula-editor-mobile-overflow

Conversation

@Furox-Art

@Furox-Art Furox-Art commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What

The formula editor overflows the viewport on phones. formula-editor.tsx gave the card a flat minWidth: 600, and the editor opens in a flyout anchored to a property header, so at a 375px viewport the card was 600px wide and the page scrolled sideways.

Changes

Card width — minWidth: 600 → width: min(600px, calc(100vw - 32px)). Still 600px on a wide screen, never wider than the viewport minus 16px gutters.

Two more minWidth: 500 floors — property-detail.tsx and function-detail.tsx carried the same kind of fixed floor and would have overflowed on their own; they now use the same min(500px, calc(100vw - 32px)).

Single-column grids at 375px — both grids drop to one column:

@media (max-width: 375px) {
  .formula-properties__grid,
  .formula-functions__grid {
    grid-template-columns: 1fr;
  }
}

Two details were needed to make that actually work:

  • The properties grid's grid-template-columns was an inline style, and inline styles beat any stylesheet rule, so a media query alone would have had no effect. The template moved into formula-bar.scss as .formula-properties__grid.
  • The media query sits last in the file on purpose. It has the same specificity as the two base rules, so only source order makes it win.
  • Both card item groups now set minWidth: 0. The shared card primitive pins min-width: max-content, which refuses to shrink below content width and would have kept the panels wide inside a viewport-bound card.

How it was tested

Measured in headless Chromium against the compiled card.scss + formula-bar.scss, so the shipped rules (including the new media query) are what's being measured. Headless Chrome clamps --window-size to 500 CSS px, so each width was driven through an iframe sized to exactly that viewport — 100vw and media queries resolve against the iframe's own initial containing block.

viewport before after
320px overflow by 302px no overflow, 288px card
375px overflow by 247px no overflow, 343px card, 1 column
480px overflow by 142px no overflow, 448px card, 2 columns
600px overflow by 22px no overflow, 568px card, 3 columns
900px no overflow, 868px card no overflow, 600px card
1280px no overflow, 1248px card no overflow, 600px card

At 375px both grids report a single 323px column with each item on its own row; at 480px+ they reflow to multiple columns. The card is pinned at exactly 600px from 632px viewport width upward.

Project checks, all passing locally, using CI's own commands:

npx tsc --noEmit -p tsconfig.app.json                          → exit 0
node scripts/check-i18n.mjs                                    → ✔ Translations OK
npx eslint --no-warn-ignored <5 changed files, CI's filter>    → exit 0
npm run build                                                  → ✓ built in 20.51s

CI

The workflow run on this PR is sitting at action_required with 0 jobs — that's GitHub's approval gate for workflows from fork pull requests, not a failure. Every previous pull_request run in this repo that succeeded came from Sall25/folio itself; the fork PRs never ran. Approving the run needs admin rights on the repository, which I don't have, so CI stays pending until someone with admin clicks approve. The commands above are exactly what CI runs, so they should pass once it does.

Not tested

I could not click through the real UI: the editor lives behind a signed-in session with a Supabase .env.local, and the landing-page editor doesn't render the database property config. The measurements above are against the real compiled CSS in a real engine, but not against live React render output. Worth a quick look on a phone to confirm the flyout also positions correctly now that it's narrower — Radix collision handling should shift it, but that's the one thing static layout can't show.

Closes #200

The formula editor card carried a flat `minWidth: 600`, and the editor
opens in a flyout anchored to a property header, so on a phone the card
was 600px wide inside a 375px viewport and the page scrolled sideways
(~247px of horizontal overflow measured at 375px).

The card is now `width: min(600px, calc(100vw - 32px))`: still 600px on
a wide screen, but never wider than the viewport minus the 16px gutters.
The two detail panels carried their own `minWidth: 500` floor and get the
same treatment.

The properties and functions grids also collapsed to a single column at
375px — the 150px/120px column floors still forced two cramped columns in
a ~343px card. The properties grid's template moved from an inline style
to CSS so the media query can actually override it, and both card item
groups drop the primitive's `min-width: max-content`, which would
otherwise stop them narrowing.

Verified at 320/375/480/600/900/1280px: no horizontal overflow at any
width, single column at 375px, 600px card on desktop.

Closes #200

Signed-off-by: Furox-Art <[email protected]>
@vercel

vercel Bot commented Oct 12, 2026

Copy link
Copy Markdown

@Furox-Art is attempting to deploy a commit to the sall25's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Sall25

Sall25 commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Thanks @Furox-Art — clear write-up and the right fix. Dropping the primitive's min-width: max-content on the panels and moving the grid template into CSS (with the comment on source order) are exactly what was needed. 👍

One small follow-up, not blocking:

FunctionDetail and PropertyDetail now use minWidth: min(500px, calc(100vw - 32px)), which is the card's outer width. They sit inside the card's padding (2 × 6px) plus CardBody's padding (2 × 10px), so on narrow screens they're ~32px wider than the space they're in. At 375px: card 343px, content ≈ 311px, panel min 343px. The page doesn't scroll (the card body is overflow-y: auto, so it scrolls itself sideways), which is likely why the page-level check passed — but there's a small horizontal scroll inside the card below ~630px.

Something like minWidth: "min(500px, 100%)" (or dropping the floor and keeping width: "100%") would keep 500px on desktop and fit the content box on phones.

Also worth knowing: with width instead of minWidth, the card no longer grows for long, non-wrapping example strings in the function help — those will scroll inside the card on desktop now. Seems like the right trade, just flagging it.

Approving — the follow-up can be a separate small PR.

@Sall25
Sall25 merged commit 495f821 into Sall25:main Oct 12, 2026
1 of 2 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.

Formula editor overflows the screen on phones (minWidth: 600)

2 participants