Repository navigation
perf(text): lazy-load truncation tooltip to reduce bundle size - #158
Conversation
XDSText and XDSHeading now lazy-load the tooltip/layer system via React.lazy instead of importing it statically. The 12KB layer system (useXDSTooltip, useXDSLayer, useXDSPopover) is only loaded when text actually overflows. - Add anchorRef prop to XDSTooltip for sibling-mode rendering - Create LazyTruncationTooltip as the dynamic import target - Use native title attribute as fallback during chunk load - Children never remount (tooltip renders as sibling via ref) Fixes #157 Co-authored-by: Navi <[email protected]>
PR Analysis Report📚 Storybook PreviewModified ComponentsLayer
Text
Bundle Size Summary
Accessibility AuditStatus: 4 accessibility violation(s) found. XDSText - 2 issue(s)
XDSTextArea - 1 issue(s)
XDSTextInput - 1 issue(s)
Component PreviewsIncludes interactive hover previews as animated GIFs. XDSTextBodyScreenshot: Interaction Preview: (view video) Run LargeScreenshot: Interaction Preview: (view video) Run LabelScreenshot: Interaction Preview: (view video) Run SupportingScreenshot: Interaction Preview: (view video) Run CodeScreenshot: Interaction Preview: (view video) Run All TypesScreenshot: Interaction Preview: (view video) Run Color VariantsScreenshot: Interaction Preview: (view video) Run Weight VariantsScreenshot: Interaction Preview: (view video) Run Display ModesScreenshot: Interaction Preview: (view video) Run Single Line TruncationScreenshot: Interaction Preview: (view video) Run Multi Line TruncationScreenshot: Interaction Preview: (view video) Run Truncation Without TooltipScreenshot: Interaction Preview: (view video) Run Truncation VariantsScreenshot: Interaction Preview: (view video) Run Word Break VariantsScreenshot: Interaction Preview: (view video) Run Text Wrap VariantsScreenshot: Interaction Preview: (view video) Run StrikethroughScreenshot: Interaction Preview: (view video) Run Tabular NumbersScreenshot: Interaction Preview: (view video) Run CapsizeScreenshot: Interaction Preview: (view video) Run As ElementsScreenshot: Interaction Preview: (view video) Run Card ExampleScreenshot: Interaction Preview: (view video) Run Metrics ExampleScreenshot: Interaction Preview: (view video) Run Form ExampleScreenshot: Interaction Preview: (view video) Run Generated by PR Enrichment workflow | Storybook | View full report |
| @@ -0,0 +1,62 @@ | |||
| /** | |||
There was a problem hiding this comment.
Can we avoid creating this file and use XDSTooltip directly with React.lazy?
…directly
Address review feedback: instead of a wrapper file, use React.lazy
with .then() to re-export XDSTooltip as a default export inline:
const LazyXDSTooltip = lazy(() =>
import('../Layer/XDSTooltip').then(mod => ({ default: mod.XDSTooltip }))
);
The truncation tooltip content styling (max-width, word-break) is
inlined at the render site in XDSText and XDSHeading.
Co-authored-by: Navi <[email protected]>
|
Addressed — removed const LazyXDSTooltip = lazy(() =>
import('../Layer/XDSTooltip').then((mod) => ({default: mod.XDSTooltip})),
);The truncation content styling ( |
* perf(text): lazy-load truncation tooltip to reduce bundle size XDSText and XDSHeading now lazy-load the tooltip/layer system via React.lazy instead of importing it statically. The 12KB layer system (useXDSTooltip, useXDSLayer, useXDSPopover) is only loaded when text actually overflows. - Add anchorRef prop to XDSTooltip for sibling-mode rendering - Create LazyTruncationTooltip as the dynamic import target - Use native title attribute as fallback during chunk load - Children never remount (tooltip renders as sibling via ref) Fixes #157 Co-authored-by: Navi <[email protected]> * refactor: remove LazyTruncationTooltip wrapper, lazy-load XDSTooltip directly Address review feedback: instead of a wrapper file, use React.lazy with .then() to re-export XDSTooltip as a default export inline: const LazyXDSTooltip = lazy(() => import('../Layer/XDSTooltip').then(mod => ({ default: mod.XDSTooltip })) ); The truncation tooltip content styling (max-width, word-break) is inlined at the render site in XDSText and XDSHeading. Co-authored-by: Navi <[email protected]> --------- Co-authored-by: Navi <[email protected]>
* perf(text): lazy-load truncation tooltip to reduce bundle size XDSText and XDSHeading now lazy-load the tooltip/layer system via React.lazy instead of importing it statically. The 12KB layer system (useXDSTooltip, useXDSLayer, useXDSPopover) is only loaded when text actually overflows. - Add anchorRef prop to XDSTooltip for sibling-mode rendering - Create LazyTruncationTooltip as the dynamic import target - Use native title attribute as fallback during chunk load - Children never remount (tooltip renders as sibling via ref) Fixes #157 * refactor: remove LazyTruncationTooltip wrapper, lazy-load XDSTooltip directly Address review feedback: instead of a wrapper file, use React.lazy with .then() to re-export XDSTooltip as a default export inline: const LazyXDSTooltip = lazy(() => import('../Layer/XDSTooltip').then(mod => ({ default: mod.XDSTooltip })) ); The truncation tooltip content styling (max-width, word-break) is inlined at the render site in XDSText and XDSHeading. ---------
Summary
XDSText and XDSHeading now lazy-load the tooltip/layer system via
React.lazyinstead of importing it statically. The ~12KB layer system (useXDSTooltip,useXDSLayer,useXDSPopover) is only loaded when text actually overflows.Changes
Add
anchorRefprop toXDSTooltip— enables sibling-mode rendering where the tooltip attaches to an external ref instead of wrapping children. WhenanchorRefis provided (and no children), the tooltip renders only the popover element.Create
LazyTruncationTooltip— a thin wrapper aroundXDSTooltipthat serves as the dynamic import target forReact.lazy. This is the code-split boundary.Update
XDSTextandXDSHeading— replace staticuseXDSTooltipimport with lazy-loadedLazyTruncationTooltip:titleattribute provides fallback while chunk loads<Suspense fallback={null}>How it works
Testing
All 749 tests pass ✅
Fixes #157
Crafted with care by Navi