An open source design system that's fully customizable and agent ready
TypeScript
perf(BottomSheet): take the sheet's open height from the ResizeObserver, not a forced measure (#9747)
Cindy Zhang199fa9bb089f
diff --git a/.changeset/bottomsheet-open-no-forced-measure.md b/.changeset/bottomsheet-open-no-forced-measure.mdnew file mode 100644index 0000000000..7241063e54--- /dev/null+++ b/.changeset/bottomsheet-open-no-forced-measure.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[perf] BottomSheet: opening a sheet no longer forces a layout to measure its height while it mounts; the sheet reads its height from the browser's own layout instead. On a phone-sized page with a 4× slowed CPU, a Selector's sheet shows its first frame about one frame sooner (about 110 ms to 94 ms after the tap) and the open does about 7 ms less forced layout. The open motion and the sheet's size are unchanged.++@cixzhangdiff --git a/packages/core/src/BottomSheet/useSheetGestures.ts b/packages/core/src/BottomSheet/useSheetGestures.tsindex 8bfd248ed3..c49fb9a465 100644--- a/packages/core/src/BottomSheet/useSheetGestures.ts+++ b/packages/core/src/BottomSheet/useSheetGestures.ts@@ -738,7 +738,9 @@ export function useSheetGestures({}return;}- recordSheetHeight(node.getBoundingClientRect().height);+ // No measure here: reading the height while the sheet mounts forces a+ // layout in the middle of the open. The observer's first report comes+ // after the browser's own layout, before the first paint.const ro = new ResizeObserver(entries => {const entry = entries[0];if (entry) {