Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -781,16 +781,25 @@ function Search({
cancelSubmitFollowUpActionSpan();
}
didBailToFallbackState.current = true;
onContentReady?.();
}, [onContentReady]);
}, []);

// When the render bails to an error/empty state, the SelectionList never mounts
// so its onLayout callback (the primary flush site) never fires. This effect
// catches that case and flushes immediately after commit. No dependency array
// is intentional — we need to check after every render since bail-outs happen
// in conditional returns that can't trigger state-based effects.
useEffect(() => {
if (!didBailToFallbackState.current || !hasDeferredWrite(CONST.DEFERRED_LAYOUT_WRITE_KEYS.SEARCH)) {
if (!didBailToFallbackState.current) {
return;
}
// Signal overlay readiness here (post-commit) rather than inside
// cancelNavigationSpans (render phase). Calling onContentReady during
// render updates the parent SearchPage while Search is still rendering,
// which triggers React's "Cannot update a component while rendering a
// different component" warning. setIsSearchReady is idempotent, so
// firing this on every bail-out render is safe.
onContentReady?.();
if (!hasDeferredWrite(CONST.DEFERRED_LAYOUT_WRITE_KEYS.SEARCH)) {
return;
}
didBailToFallbackState.current = false;
Expand Down
Loading