Skip to content

Commit a17aac2

Browse files
Virtualizer: Ensure child render function updates children immediatly (#33788)
1 parent a826c3b commit a17aac2

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "fix: Fix regression of child render function update",
4+
"packageName": "@fluentui/react-virtualizer",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/react-virtualizer/library/src/components/Virtualizer/useVirtualizer.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ export function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerSta
104104
const initializeScrollingTimer = React.useCallback(() => {
105105
if (!enableScrollLoad) {
106106
// Disabled by default for reduction of render callbacks
107+
setIsScrolling(false);
108+
clearScrollTimer();
107109
return;
108110
}
109111
/*
@@ -514,17 +516,15 @@ export function useVirtualizer_unstable(props: VirtualizerProps): VirtualizerSta
514516

515517
/*
516518
* forceUpdate:
517-
* We only want to trigger this when scrollLoading is enabled and set to false,
519+
* We only want to trigger this when child render or scroll loading changes,
518520
* it will force re-render all children elements
519521
*/
520522
const forceUpdate = React.useReducer(() => ({}), {})[1];
521523
// If the user passes in an updated renderChild function - update current children
522524
React.useEffect(() => {
523525
if (actualIndex >= 0) {
524526
updateChildRows(actualIndex);
525-
if (enableScrollLoad && !isScrolling) {
526-
forceUpdate();
527-
}
527+
forceUpdate();
528528
}
529529
// eslint-disable-next-line react-hooks/exhaustive-deps
530530
}, [renderChild, isScrolling]);

0 commit comments

Comments
 (0)