Skip to content

Commit

Permalink
fix list is not visible initially
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed Apr 1, 2024
1 parent 5450717 commit 4a2da6a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function BaseSelectionList<TItem extends ListItem>(
) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const firstLayoutRef = useRef(true);
const listRef = useRef<RNSectionList<TItem, SectionWithIndexOffset<TItem>>>(null);
const innerTextInputRef = useRef<RNTextInput | null>(null);
const focusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
Expand All @@ -83,7 +84,6 @@ function BaseSelectionList<TItem extends ListItem>(
const activeElementRole = useActiveElementRole();
const isFocused = useIsFocused();
const [maxToRenderPerBatch, setMaxToRenderPerBatch] = useState(shouldUseDynamicMaxToRenderPerBatch ? 0 : CONST.MAX_TO_RENDER_PER_BATCH.DEFAULT);
const [isInitialSectionListRender, setIsInitialSectionListRender] = useState(true);
const [itemsToHighlight, setItemsToHighlight] = useState<Set<string> | null>(null);
const itemFocusTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const [currentPage, setCurrentPage] = useState(1);
Expand Down Expand Up @@ -349,13 +349,13 @@ function BaseSelectionList<TItem extends ListItem>(
setMaxToRenderPerBatch((Math.ceil(listHeight / itemHeight) || 0) + CONST.MAX_TO_RENDER_PER_BATCH.DEFAULT);
}

if (!isInitialSectionListRender) {
if (!firstLayoutRef.current) {
return;
}
scrollToIndex(focusedIndex, false);
setIsInitialSectionListRender(false);
firstLayoutRef.current = false;
},
[focusedIndex, isInitialSectionListRender, scrollToIndex, shouldUseDynamicMaxToRenderPerBatch],
[focusedIndex, scrollToIndex, shouldUseDynamicMaxToRenderPerBatch],
);

const onSectionListLayout = useCallback(
Expand Down Expand Up @@ -573,7 +573,7 @@ function BaseSelectionList<TItem extends ListItem>(
viewabilityConfig={{viewAreaCoveragePercentThreshold: 95}}
testID="selection-list"
onLayout={onSectionListLayout}
style={(!maxToRenderPerBatch || isInitialSectionListRender) && styles.opacity0}
style={!maxToRenderPerBatch && styles.opacity0}
ListFooterComponent={ShowMoreButtonInstance}
/>
{children}
Expand Down

0 comments on commit 4a2da6a

Please sign in to comment.