topbar: pick nav tier by measuring overflow instead of breakpoints - #106
topbar: pick nav tier by measuring overflow instead of breakpoints#106ali616csayed wants to merge 1 commit into
Conversation
Original prompt from Ali
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: ali@deeptrust.ai <alialsayed616c@gmail.com>
b3073f3 to
3a95709
Compare
Summary
The topbar picked its nav tier (full labels → icons only → hamburger) from fixed container-query breakpoints at 1150px/900px, and the row was
wrap="wrap". The room left for the nav depends on the breadcrumb, which varies per page and per org, not on the container width — so on pages with a long breadcrumb the nav still didn't fit at a width the breakpoints considered roomy, and instead of degrading, the row wrapped: breadcrumb on line 1, nav links on line 2, avatar on line 3.The tier is now chosen by measuring actual overflow, and the row never wraps:
Notes on the non-obvious parts:
setStatein a layout effect is a lint error here anyway.navMenuOpenstays in state — it drives the Radix dropdown — and is closed whenever a wider tier wins, since the hamburger trigger only exists atmenu.flexGrow="1" minWidth="0", so it shrinks to whatever the row leaves it and lets its own content spill; the topbar itself then reportsscrollWidth === clientWidthand would never see the overflow.ResizeObserveralone would leave the nav collapsed on a page that now has room..topbargetsoverflow: hiddenso a row that overflows even atmenuis clipped rather than reflowed, and atmenuthe breadcrumb becomes shrinkable. Labels are still visually hidden (not removed) at theiconstier, so links keep their accessible name, and each anchor keeps itstitle.Verified in the web app, which consumes this via the submodule (deeptrust-ai/web#801), with a viewport sweep from 360px to 1440px across the main routes and every Settings tab: topbar height constant, all controls on one row, no clipped nav, tier transitions where the content actually stops fitting (e.g. Desktop Downloads, with the longest breadcrumb, drops to icons ~100px earlier than Configurations).
Before (long org breadcrumb, ~1200px — the reported break) and after:
Prettier reformatted a few unrelated blocks in
Topbar.tsxthat were not previously formatted; those hunks are formatting only.Link to Devin session: https://app.devin.ai/sessions/79734bf9b62b4b7a93efb9578595d14d
Requested by: @ali616csayed