fix(ui,panel): float a section glyph's colors on the window's layer, never clipped

Merged
DA
1d ago
+298-191

What was wrong

Dean reported that on iPhone (Tasks tab), picking the flag for a section icon opened a color menu that was clipped under the Icons/Emoji tabs and covered Recent and Suggested.

Which client: the shared web panel (packages/panel's section-icon-picker.tsx over @repo/ui's IconPicker) in a phone browser. The iOS app has no section icon picker; its @repo/ui-native IconPickerSheet only picks Manager faces.

Cause: the colors hung as an AnchoredPopover inside the picker's scrolling grid. AnchoredPopover cuts itself to every box around it that clips (clip-room.ts), and here that's the grid's 220px scroll area. At phone sizes the menu fit neither above nor below the glyph, so it was clipped at the grid's top.

The fix

The colors still float from the glyph as a submenu, but they're never clipped:

  • @repo/ui's IconPickerChoice takes a flyout and hangs it from its own button through Base UI's popover (the same primitive behind PopoverIconButton). It renders in a portal on the window's layer, uses the visible window as its collision boundary instead of the scroll grid, and flips or shifts to fit. On a phone it overlaps the picker's own choices where it must, and can run past the picker's edge, rather than being cut.
  • It nests in the picker's own Base UI popover, so a press inside it doesn't close the picker. It takes the picker's layer (over a dialog's card where the picker is), so it's never drawn under it.
  • Keyboard behavior is shared in the flyout: the selected color (or the first) takes focus on open, arrows move between colors, and Escape or a press away closes it and returns focus to the glyph. Pressing the glyph again closes it.
  • The grid's tab-stop bookkeeping ignores focus inside the flyout (React carries a portal's events up the tree), replacing the old ICON_PICKER_ASIDE class.
  • The catalog's icon picker example floats a Flag flyout.

Nothing is inserted into the grid, so opening the colors re-renders only the pressed cell. Desktop and web share the component; the desktop shots show it looks the same as before there.

Screenshots

Playwright at iPhone 15 Pro size (393×852 @3x) and 1280×800, on the web dev app with ?fixture=inbox.

BeforeAfter
iPhone, Recent flag (Dean's case)
iPhone, Suggested flag
Desktop, Recent flag

Note: on the web dev server the picker says "The icons could not be loaded", because the dev server's on-demand Lucide module doesn't export icons (CJS interop). For the screenshots I served Lucide's ES build in its place. That bug was already there; Bug Fixer filed it separately.

Focus timing (after the merge queue's first run)

Base UI moves a popover's first focus on the next animation frame. A key pressed in that frame (an Enter right after Shift-Enter in the search, or right after clicking a glyph) would land on the glyph or the search and close the colors. A real keyboard user could hit that, so it's fixed in the app, not only in the tests: the flyout focuses its starting color as soon as it appears. A test with animation frames stubbed out covers it, failing without the fix.

Checking that in Chromium surfaced three focus and closing bugs, now fixed:

  • Only Escape returns focus to the glyph. Before, when another glyph's colors replaced the open ones, the old popover's late return-focus pulled focus back to the old glyph.
  • A popover that's already gone can no longer close the one that replaced it.
  • Pressing the glyph again with a real mouse now closes its colors. Before, moving focus onto the glyph on mouse-down closed them, and the click then reopened them.

The tests also wait for focus to land before pressing a color.

Tests

  • Ran: packages/panel/src/desktop/sidebar-sections.test.ts, all 67 passing (color choice, Escape, arrows, glyph toggle, Recent's starting color; selector now .ui-icon-picker-flyout), and manager-face-picker.test.ts. This sandbox ran slow today: every picker test took 5–7s, main's included, so I ran with a longer --testTimeout. CI passed the same tests at the default timeout on earlier commits.
  • Removed: the inline drawer's test, since the drawer is gone.
  • Typechecked packages/panel and apps/catalog (tsc -b). Ran oxlint and biome on the changed files.
  • Left to CI: everything else.

🤖 Generated with Claude Code