From 8f7d79afa0ab15b7dc0d7022415cc85b24c27f61 Mon Sep 17 00:00:00 2001 From: jacob314 Date: Wed, 6 May 2026 15:25:18 -0700 Subject: [PATCH] use onStaticRender in VirtualizedList --- package-lock.json | 10 ++-- package.json | 4 +- packages/cli/package.json | 2 +- .../ui/components/shared/VirtualizedList.tsx | 46 +++++++++---------- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/package-lock.json b/package-lock.json index 59f4c82fab..bd042a2a04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "packages/*" ], "dependencies": { - "ink": "npm:@jrichman/ink@7.0.0-beta.3", + "ink": "npm:@jrichman/ink@7.0.1-beta.0", "latest-version": "^9.0.0", "node-fetch-native": "^1.6.7", "proper-lockfile": "^4.1.2", @@ -10020,9 +10020,9 @@ }, "node_modules/ink": { "name": "@jrichman/ink", - "version": "7.0.0-beta.3", - "resolved": "https://registry.npmjs.org/@jrichman/ink/-/ink-7.0.0-beta.3.tgz", - "integrity": "sha512-8qBJlbUg1HRfOtLlGo6NjGL+HwYrwkoyvLXOl6Ogzcf2l0n0hudiaPpD+0VFTCQX3o01Nm5bMr4zY5TXwEXvgA==", + "version": "7.0.1-beta.0", + "resolved": "https://registry.npmjs.org/@jrichman/ink/-/ink-7.0.1-beta.0.tgz", + "integrity": "sha512-vRzRMXNspq92OgikN2RTC0cpyErUn/OCQ97cAWikMEcy/dd8MZ/5SLisyZPL9t8Qt0LLIlY2WOB0cLkCj18qtQ==", "license": "MIT", "dependencies": { "ansi-escapes": "^7.0.0", @@ -18228,7 +18228,7 @@ "fzf": "^0.5.2", "glob": "^12.0.0", "highlight.js": "^11.11.1", - "ink": "npm:@jrichman/ink@7.0.0-beta.3", + "ink": "npm:@jrichman/ink@7.0.1-beta.0", "ink-gradient": "^3.0.0", "ink-spinner": "^5.0.0", "latest-version": "^9.0.0", diff --git a/package.json b/package.json index 9d50f0fa7d..b2bc389ca7 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "pre-commit": "node scripts/pre-commit.js" }, "overrides": { - "ink": "npm:@jrichman/ink@7.0.0-beta.3", + "ink": "npm:@jrichman/ink@7.0.1-beta.0", "wrap-ansi": "9.0.2", "cliui": { "wrap-ansi": "7.0.0" @@ -143,7 +143,7 @@ "yargs": "^17.7.2" }, "dependencies": { - "ink": "npm:@jrichman/ink@7.0.0-beta.3", + "ink": "npm:@jrichman/ink@7.0.1-beta.0", "latest-version": "^9.0.0", "node-fetch-native": "^1.6.7", "proper-lockfile": "^4.1.2", diff --git a/packages/cli/package.json b/packages/cli/package.json index 3ba4e50129..fc83c321e4 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -49,7 +49,7 @@ "fzf": "^0.5.2", "glob": "^12.0.0", "highlight.js": "^11.11.1", - "ink": "npm:@jrichman/ink@7.0.0-beta.3", + "ink": "npm:@jrichman/ink@7.0.1-beta.0", "ink-gradient": "^3.0.0", "ink-spinner": "^5.0.0", "latest-version": "^9.0.0", diff --git a/packages/cli/src/ui/components/shared/VirtualizedList.tsx b/packages/cli/src/ui/components/shared/VirtualizedList.tsx index 6354f34788..941d1db60a 100644 --- a/packages/cli/src/ui/components/shared/VirtualizedList.tsx +++ b/packages/cli/src/ui/components/shared/VirtualizedList.tsx @@ -108,24 +108,6 @@ function findLastIndex( return -1; } -const MemoizedStaticItem = memo( - ({ - content, - width, - itemKey, - }: { - content: React.ReactElement; - width: number; - itemKey: string; - }) => ( - - {() => content} - - ), -); - -MemoizedStaticItem.displayName = 'MemoizedStaticItem'; - const VirtualizedListItem = memo( ({ content, @@ -301,6 +283,22 @@ function VirtualizedList( prevContainerHeight: -1, }); + const onStaticRender = useCallback( + (index: number, key: string, node: DOMElement) => { + const height = Math.round(getBoundingBox(node).height); + if ( + height > 0 && + (state.current.measuredHeights[index] !== height || + state.current.measuredKeys[index] !== key) + ) { + state.current.measuredHeights[index] = height; + state.current.measuredKeys[index] = key; + setMeasurementVersion((v) => v + 1); + } + }, + [], + ); + const itemsObserver = useMemo( () => new ResizeObserver((entries) => { @@ -775,12 +773,13 @@ function VirtualizedList( if (shouldBeStatic) { items.push( - , + onRender={(node: DOMElement) => onStaticRender(i, key, node)} + > + {() => content} + , ); } else { items.push( @@ -829,6 +828,7 @@ function VirtualizedList( onSetRef, estimatedItemHeight, temporarilyInteractiveIndexes, + onStaticRender, ]); const { getScrollTop, setPendingScrollTop } = useBatchedScroll(scrollTop);