From 3ffec3a91408de11c1cd9928304661d50ab2cd79 Mon Sep 17 00:00:00 2001 From: bartektomczyk Date: Tue, 2 Jan 2024 11:47:32 +0100 Subject: [PATCH] fix: move hiding only to the SectionList --- src/components/SelectionList/BaseSelectionList.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/SelectionList/BaseSelectionList.js b/src/components/SelectionList/BaseSelectionList.js index 213c55e8d8b9..88c4018f823c 100644 --- a/src/components/SelectionList/BaseSelectionList.js +++ b/src/components/SelectionList/BaseSelectionList.js @@ -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: @@ -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( @@ -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; } @@ -401,7 +400,7 @@ function BaseSelectionList({ {/* */} {({safeAreaPaddingBottomStyle}) => ( - + {shouldShowTextInput && ( {children}