Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move hiding only to the SectionList #33833

Merged
merged 1 commit into from
Jan 4, 2024
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: 7 additions & 8 deletions src/components/SelectionList/BaseSelectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ function BaseSelectionList({
const activeElement = useActiveElement();
const isFocused = useIsFocused();
const [maxToRenderPerBatch, setMaxToRenderPerBatch] = useState(shouldUseDynamicMaxToRenderPerBatch ? 0 : CONST.MAX_TO_RENDER_PER_BATCH.DEFAULT);
const [isInitialRender, setIsInitialRender] = useState(true);
const wrapperStyles = useMemo(() => ({opacity: isInitialRender ? 0 : 1}), [isInitialRender]);
const [isInitialSectionListRender, setIsInitialSectionListRender] = useState(true);

/**
* Iterates through the sections and items inside each section, and builds 3 arrays along the way:
Expand Down Expand Up @@ -331,13 +330,13 @@ function BaseSelectionList({
setMaxToRenderPerBatch((Math.ceil(listHeight / itemHeight) || 0) + CONST.MAX_TO_RENDER_PER_BATCH.DEFAULT);
}

if (!isInitialRender) {
if (!isInitialSectionListRender) {
return;
}
scrollToIndex(focusedIndex, false);
setIsInitialRender(false);
setIsInitialSectionListRender(false);
},
[focusedIndex, isInitialRender, scrollToIndex, shouldUseDynamicMaxToRenderPerBatch],
[focusedIndex, isInitialSectionListRender, scrollToIndex, shouldUseDynamicMaxToRenderPerBatch],
);

const updateAndScrollToFocusedIndex = useCallback(
Expand Down Expand Up @@ -365,7 +364,7 @@ function BaseSelectionList({

useEffect(() => {
// do not change focus on the first render, as it should focus on the selected item
if (isInitialRender) {
if (isInitialSectionListRender) {
return;
}

Expand Down Expand Up @@ -401,7 +400,7 @@ function BaseSelectionList({
{/* <View style={[styles.flex1, !isKeyboardShown && safeAreaPaddingBottomStyle, wrapperStyle]}> */}
<SafeAreaConsumer>
{({safeAreaPaddingBottomStyle}) => (
<View style={[styles.flex1, !isKeyboardShown && safeAreaPaddingBottomStyle, wrapperStyles, StyleUtils.parseStyleAsArray(containerStyle)]}>
<View style={[styles.flex1, !isKeyboardShown && safeAreaPaddingBottomStyle, StyleUtils.parseStyleAsArray(containerStyle)]}>
{shouldShowTextInput && (
<View style={[styles.ph5, styles.pb3]}>
<TextInput
Expand Down Expand Up @@ -479,7 +478,7 @@ function BaseSelectionList({
viewabilityConfig={{viewAreaCoveragePercentThreshold: 95}}
testID="selection-list"
onLayout={scrollToFocusedIndexOnFirstRender}
style={!maxToRenderPerBatch && styles.opacity0}
style={(!maxToRenderPerBatch || isInitialSectionListRender) && styles.opacity0}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hiding this using isInitialSectionListRender was causing the contacts to show up on the confirmation page with a delay (#39245) so we fixed this in #39364

/>
{children}
</>
Expand Down
Loading