Skip to content

armgit / bento

Public Imported from GitHub
0

Bento, the office suite that fits in a file

slides: the toolbar scrolls instead of being cut off on a 320px phone (#274)

iamgeo92b81a66dd0e45
diff --git a/CLAUDE.md b/CLAUDE.md
index 5187cfd5..2021baf1 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -530,12 +530,26 @@ names provisional.
all (verified against pre-change code too) — resize behavior needs a
real mouse. Present: real fullscreen via overlay.requestFullscreen at start +
F toggle (denied requests degrade to tab-fill — that IS the testing/
- sharing mode). Topbar is responsive by HIDING TEXT, never scrolling — and by
- MEASURING, not width breakpoints (zoom/OS text scale/locale width made px
- queries clip the bar): editor.ts fitTopbar() steps down tier classes while
- the bar overflows (ed-bar-compact hides labels, ed-bar-tight the wordmark,
- ed-bar-fold folds into menus via applyPhoneChrome), driven by a Resize- +
- MutationObserver on the bar.
+ sharing mode). Topbar is responsive by HIDING TEXT rather than
+ scrolling — and by MEASURING, not width breakpoints (zoom/OS text scale/
+ locale width made px queries clip the bar): editor.ts fitTopbar() steps down
+ tier classes while the bar overflows (ed-bar-compact hides labels,
+ ed-bar-tight the wordmark, ed-bar-fold folds into menus via
+ applyPhoneChrome), driven by a Resize- + MutationObserver on the bar.
+ **Below the fold's floor it DOES scroll, and that is not a retreat from the
+ above.** Fully folded the bar still needs ~356px — six 44px touch targets,
+ the mark and the title — and an iPhone SE (or any iPhone with Display Zoom
+ on) is 320px. `.ed-root` is `overflow: hidden` so a wide bar can never become
+ document scroll, so the excess was simply CUT OFF: ⋯ — which on a phone
+ carries Redo, Comment, PDF, Share, Language, Help and the whole save-as list
+ — sat at x=356 on a 320px screen and could not be reached at all (measured,
+ not inferred). Hiding text is still the strategy and still does all the work;
+ scrolling is only the floor beneath it, for the widths where the fold has
+ already surrendered everything it has. Consequence to respect: a scroll
+ container clips BOTH axes (see hard-won detail 10), so the menus hanging off
+ + and ⋯ are `position: fixed` and editor.ts publishes --ed-bar-bottom for
+ them, the one thing they cannot read from CSS because it moves with the
+ safe-area insets.
Panel show/hide lives ON the resizer strips as chevron tabs (docked
flush to the screen edge when collapsed); phones (<700px) boot with
both panels collapsed (canvas-first; chevrons/[/] bring them back).
diff --git a/slides/src/editor/editor.ts b/slides/src/editor/editor.ts
index 202d75ba..6d516086 100644
--- a/slides/src/editor/editor.ts
+++ b/slides/src/editor/editor.ts
@@ -462,6 +462,17 @@ export class Editor {
attributes: true, attributeFilter: ['style', 'hidden'],
})
+ // On a narrow phone the bar scrolls sideways, which makes it a clipping
+ // container — so the menus hanging off + and ⋯ are positioned against the
+ // VIEWPORT instead (styles.css). The one thing they cannot read from CSS is
+ // where the bar ends: its height moves with the safe-area insets, which
+ // differ per device and change when the phone rotates.
+ const publishBarBottom = () =>
+ this.root.style.setProperty('--ed-bar-bottom', `${Math.round(bar.getBoundingClientRect().bottom)}px`)
+ new ResizeObserver(publishBarBottom).observe(bar)
+ window.addEventListener('resize', publishBarBottom)
+ publishBarBottom()
+
this.restorePanelWidths()
this.canvas = new SlideCanvas(canvasWrap, this.store)
this.canvas.onCommentModeChange = (on) => commentB.classList.toggle('ed-btn-armed', on)
diff --git a/slides/src/styles.css b/slides/src/styles.css
index adc3955a..9b5bbb5a 100644
--- a/slides/src/styles.css
+++ b/slides/src/styles.css
@@ -2201,6 +2201,37 @@ body.ed-col-resizing { cursor: col-resize; user-select: none; }
/* the 16px resizer chevrons are replaced by real buttons in the bar */
.ed-panel-toggle { display: none; }
.ed-title { min-width: 0; }
+
+ /* Folding is not enough on the narrowest phones. Even fully folded the bar
+ needs ~356px — six 44px targets, the mark and the title — and an iPhone SE
+ (or any iPhone with Display Zoom on) is 320px wide. `.ed-root` sets
+ `overflow: hidden` so a wide bar can never turn into DOCUMENT scroll, and
+ the consequence was that the overflow was simply CUT OFF: ⋯ — which on a
+ phone carries Redo, Comment, PDF, Share, Language, Help and the whole
+ save-as list — hung 36px off the edge and could not be reached at all.
+ So the bar scrolls itself. The clipped button is now a partly-visible one,
+ which is its own affordance, and the fix keeps scaling if the bar ever
+ gains another control. */
+ .ed-topbar {
+ overflow-x: auto;
+ /* a sideways flick on the bar must not rubber-band the page behind it */
+ overscroll-behavior-x: contain;
+ scrollbar-width: none;
+ -webkit-overflow-scrolling: touch;
+ }
+ .ed-topbar::-webkit-scrollbar { display: none; }
+ /* A scroll container clips its children in BOTH axes, so the menus hanging
+ off + and ⋯ would now be cut off by the bar itself. `fixed` takes them out
+ of that clip; it costs nothing extra to anchor, because the rule above
+ already pins these menus to the end of the screen rather than to their
+ trigger. The only thing they still need from the layout is where the bar
+ ends, which editor.ts publishes as --ed-bar-bottom. */
+ .ed-topbar .ed-dropdown.open > .ed-menu {
+ position: fixed;
+ top: calc(var(--ed-bar-bottom, 56px) + 4px);
+ inset-inline-end: max(6px, env(safe-area-inset-right), var(--tray-safe-right, 0px));
+ inset-inline-start: auto;
+ }
}
/* panel collapse chevrons live ON the resizer strips, not in the topbar */