feat(ui): touch and small-screen behaviour for shared components

GU
2d ago
+956-236

Summary

Issue: no ticket

First half of #3241, split for review (second half: #3258). This PR changes shared components and utilities only. It keeps min-width: 44.5rem on body, so phones still get the current desktop layout and nothing changes for users until the layout PR lands.

Every change applies below md, on touch screens (pointer: coarse), or has no visible effect at desktop widths.

  • Utilities: isTouchScreen and scrollIntoViewHorizontally in util-js, useHorizontalOverflowFade in util-hooks (fades the edge of a horizontal scroller that hides more content, below md only), mockPointerCoarse in util-tests.
  • Tooltip: opens on tap on touch screens when the trigger is not itself a button or link; closes on a tap outside. collisionPadding 8 and max-w-[calc(100vw-32px)] so it never leaves the screen.
  • Popover: on touch screens it focuses itself on open instead of its first field, so the keyboard does not cover it.
  • Inputs (InputText, InputTextSmall, InputSearch, InputSelect, MultipleSelector, Copilot input): autoFocus is skipped on touch screens. InputText gets an inputMode prop.
  • Sidebar: below md the list collapses behind a button that shows the current section. Arrow keys still move between links only.
  • Navbar and table primitives: keep the active tab in view and fade the hidden edge.
  • Breadcrumbs: scroll to the current scope when the trail overflows, again on resize.
  • Tap targets: an invisible halo on ButtonPrimitive (44px) and Checkbox (40px) on touch screens; toolbar buttons only extend vertically so neighbours do not overlap; the Spotlight trigger becomes a search icon below md.
  • Modal and command menu: fit the viewport width, overscroll-contain.
  • main.scss: on touch screens, 16px fields (iOS Safari zooms into smaller ones) and touch-action: manipulation.
  • mobile-layout.ts: shared class constants the layout PR uses (sticky Save row, settings header action, deployment list columns).

Next: #3258, stacked on this one, applies the page-level classes and removes the body min-width.

Screenshots / Recordings

Full result on a phone (both PRs together): https://3241-console-staging.zc531a994.rustrocks.cloud

Testing

  • Desktop at 1024px and 1440px compared against staging: no visible change.
  • yarn test: related specs locally (jest --findRelatedTests), full run in CI.
  • New specs: isTouchScreen, scrollIntoViewHorizontally, useHorizontalOverflowFade, mobile-layout, Navbar (keyboard, active tab scroll), Sidebar (collapse, badge-free label, arrow keys), Tooltip (tap, outside tap), Popover, InputText and InputSelect touch focus.
  • yarn format
  • yarn lint on changed files

PR Checklist

  • I followed naming, styling, and TypeScript rules (see .cursor/rules)
  • I performed a self-review (diff inspected, dead code removed)
  • I titled the PR using Conventional Commits with a scope when possible
  • I only kept necessary comments, written in English
  • I involved a designer to validate UI changes if I am not a designer
  • I covered new business logic with tests (unit)
  • I confirmed CI is green (Codecov red can be accepted)
  • I reviewed and executed locally any AI-assisted code