Skip to content

✨ feat: overhaul Sidebar for MFE-resilient layout, portal tooltips and SSR-safe mode hint#632

Merged
futjesus merged 1 commit into
mainfrom
feat/sidebar-mfe-portal-tooltips
Apr 30, 2026
Merged

✨ feat: overhaul Sidebar for MFE-resilient layout, portal tooltips and SSR-safe mode hint#632
futjesus merged 1 commit into
mainfrom
feat/sidebar-mfe-portal-tooltips

Conversation

@futjesus
Copy link
Copy Markdown
Member

Summary

Substantial Sidebar rework, motivated by issues hit while integrating it into a Next.js + federated micro-frontend host:

  • Portal-rendered collapsed tooltips. The collapsed-mode label now goes through a Radix tooltip via portal, so it escapes any overflow clipping on the consumer side instead of being clipped by the rail's own scroll container.
  • MFE-resilient layout. New auto-imported Sidebar.css ships plain (un-layered) rules for the bits that federated remotes were clobbering: width / scrollbar / overflow on the nav, list reset, item / Logo padding, separator and the hover / active background. Adds stable data-konstruct-sidebar-* hooks (-logo, -label, -separator) and a style prop on the wrapper so consumers theme via CSS custom properties (--konstruct-sidebar-hover-bg, --konstruct-sidebar-active-bg, --konstruct-sidebar-logo-padding-*) — inline styles outrank any utility a remote can ship.
  • Active state via attribute. NavigationOption exposes data-active="true" so the active rule lives in the protection sheet alongside :hover, no more relying on utility classes that lose to un-layered overrides.
  • SSR-safe mode resolution. useSidebarMode now accepts an initialMode hint (typically a cookie set on the previous client visit) used as the SSR fallback, so Next-style apps no longer flash from expanded to the actual mode after hydration. The hook also probes all three breakpoint ranges explicitly so a tablet → desktop resize resolves correctly.
  • Whole-row hit area. Padding moved from the <li> to the inner <a> so navigation clicks and the Radix tooltip trigger cover the full option, not just the icon.
  • Misc polish. Wrapper width no longer transitions on mode change, scrollbar tuned to match the Storybook one, separator opacity bumped (bg-white/20), rounded (4px) on items, Logo centers in collapsed and the v1.11.1 caption gets text-center + a small pt-1.

Test plan

  • npm run lint / npm run check:types / npm run check:prettier (run by Husky on commit)
  • npx vitest run lib/components/Sidebar — all Sidebar tests passing (one collapsed-mode label assertion updated to expect sr-only instead of the legacy max-w-0)
  • Storybook story under In Review / Sidebar renders correctly across expanded, collapsed and drawer modes (logo, options, separators, hover, active)
  • Verify in a host app that:
    • No collapsed → expanded flicker on desktop hydration
    • When initialMode is provided, no expanded → collapsed flicker on tablet
    • Resizing tablet → desktop transitions correctly
    • Hover and active backgrounds survive when a federated remote's CSS bundle loads after hydration

…d SSR-safe mode hint

- Render the collapsed-mode option label via a Radix tooltip portal so it
  escapes any consumer overflow clipping, not just the sidebar rail.
- Ship a new `Sidebar.css` (auto-imported with the component) with plain
  un-layered protection rules — width, scroll, list reset, gap, item
  padding, separator, scrollbar, hover/active and Logo padding via CSS
  custom properties — so a federated remote's reset can no longer break
  the host sidebar. Adds stable `data-konstruct-sidebar-*` hooks
  (`-logo`, `-label`, `-separator`) and a `style` prop on the wrapper to
  drive the new variables.
- Hover/active styling now lives entirely in the protection sheet (with
  variables consumers set via `style`), and active items expose
  `data-active="true"` so the rule can target them without relying on
  utility classes.
- `useSidebarMode` accepts an `initialMode` hint (e.g. read from a cookie
  on the server) used as the SSR fallback so Next-style apps no longer
  flicker from `expanded` to the actual viewport mode after hydration.
  Probes all three breakpoint ranges so resizing to desktop after a
  tablet visit resolves correctly.
- Items center their icon-only content in collapsed mode and the click /
  tooltip-trigger area now covers the full option (padding moved to the
  inner anchor).
- Misc polish: drop the wrapper's width transition (no flicker on mode
  change), thin scrollbar tuned to match Storybook's, separator opacity
  bumped to bg-white/20, items use rounded (4px), Logo centers in
  collapsed and v1.11.1 caption gets text-center + pt-1 there.
@futjesus futjesus merged commit f85a13f into main Apr 30, 2026
1 check passed
@futjesus futjesus deleted the feat/sidebar-mfe-portal-tooltips branch April 30, 2026 21:21
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.

1 participant