From 838b7067d816cf42a5001ad1eed763642f731ca6 Mon Sep 17 00:00:00 2001
From: dmkt9 <demoskratos9x@gmail.com>
Date: Mon, 25 Aug 2025 00:02:38 +0700
Subject: [PATCH] Fix - search input options and filters disappear

---
 .../Search/SearchList/BaseSearchList/index.native.tsx     | 4 ++--
 src/components/Search/SearchList/BaseSearchList/index.tsx | 2 +-
 src/components/Search/SearchList/BaseSearchList/types.ts  | 2 +-
 src/components/Search/SearchList/index.tsx                | 8 +++++---
 src/pages/Search/SearchPageNarrow.tsx                     | 1 +
 5 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/components/Search/SearchList/BaseSearchList/index.native.tsx b/src/components/Search/SearchList/BaseSearchList/index.native.tsx
index 0358ffab0fa0..ae54a0cb2e54 100644
--- a/src/components/Search/SearchList/BaseSearchList/index.native.tsx
+++ b/src/components/Search/SearchList/BaseSearchList/index.native.tsx
@@ -24,8 +24,8 @@ function BaseSearchList({
     calculatedListHeight,
 }: BaseSearchListProps) {
     const renderItemWithoutKeyboardFocus = useCallback(
-        ({item}: {item: SearchListItem; index: number}) => {
-            return renderItem(item, false, undefined);
+        ({item, index}: {item: SearchListItem; index: number}) => {
+            return renderItem(item, index, false, undefined);
         },
         [renderItem],
     );
diff --git a/src/components/Search/SearchList/BaseSearchList/index.tsx b/src/components/Search/SearchList/BaseSearchList/index.tsx
index 89f4522524e8..ed394b64faeb 100644
--- a/src/components/Search/SearchList/BaseSearchList/index.tsx
+++ b/src/components/Search/SearchList/BaseSearchList/index.tsx
@@ -74,7 +74,7 @@ function BaseSearchList({
                 }
                 setFocusedIndex(index);
             };
-            return renderItem(item, isItemFocused, onFocus);
+            return renderItem(item, index, isItemFocused, onFocus);
         },
         [focusedIndex, renderItem, setFocusedIndex],
     );
diff --git a/src/components/Search/SearchList/BaseSearchList/types.ts b/src/components/Search/SearchList/BaseSearchList/types.ts
index 7447e3490de2..40c1e2c2b18a 100644
--- a/src/components/Search/SearchList/BaseSearchList/types.ts
+++ b/src/components/Search/SearchList/BaseSearchList/types.ts
@@ -24,7 +24,7 @@ type BaseSearchListProps = Pick<
     data: SearchListItem[];
 
     /** The function to render each item in the list */
-    renderItem: (item: SearchListItem, isItemFocused: boolean, onFocus?: (event: NativeSyntheticEvent<ExtendedTargetedEvent>) => void) => React.JSX.Element;
+    renderItem: (item: SearchListItem, index: number, isItemFocused: boolean, onFocus?: (event: NativeSyntheticEvent<ExtendedTargetedEvent>) => void) => React.JSX.Element;
 
     /** The length of the flattened items in the list */
     flattenedItemsLength: number;
diff --git a/src/components/Search/SearchList/index.tsx b/src/components/Search/SearchList/index.tsx
index 74e029bfecdb..2c71a06e8e3d 100644
--- a/src/components/Search/SearchList/index.tsx
+++ b/src/components/Search/SearchList/index.tsx
@@ -242,15 +242,16 @@ function SearchList(
     useImperativeHandle(ref, () => ({scrollToIndex}), [scrollToIndex]);
 
     const renderItem = useCallback(
-        (item: SearchListItem, isItemFocused: boolean, onFocus?: (event: NativeSyntheticEvent<ExtendedTargetedEvent>) => void) => {
+        (item: SearchListItem, index: number, isItemFocused: boolean, onFocus?: (event: NativeSyntheticEvent<ExtendedTargetedEvent>) => void) => {
             const isDisabled = item.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
+            const shouldApplyAnimation = shouldAnimate && index < data.length - 1;
 
             return (
                 <Animated.View
-                    exiting={shouldAnimate ? FadeOutUp.duration(CONST.SEARCH.EXITING_ANIMATION_DURATION).easing(easing) : undefined}
+                    exiting={shouldApplyAnimation ? FadeOutUp.duration(CONST.SEARCH.EXITING_ANIMATION_DURATION).easing(easing) : undefined}
                     entering={undefined}
                     style={styles.overflowHidden}
-                    layout={shouldAnimate && hasItemsBeingRemoved ? LinearTransition.easing(easing).duration(CONST.SEARCH.EXITING_ANIMATION_DURATION) : undefined}
+                    layout={shouldApplyAnimation && hasItemsBeingRemoved ? LinearTransition.easing(easing).duration(CONST.SEARCH.EXITING_ANIMATION_DURATION) : undefined}
                 >
                     <ListItem
                         showTooltip
@@ -277,6 +278,7 @@ function SearchList(
         },
         [
             shouldAnimate,
+            data.length,
             styles.overflowHidden,
             hasItemsBeingRemoved,
             ListItem,
diff --git a/src/pages/Search/SearchPageNarrow.tsx b/src/pages/Search/SearchPageNarrow.tsx
index 6a21c5b96de5..1021f983db1e 100644
--- a/src/pages/Search/SearchPageNarrow.tsx
+++ b/src/pages/Search/SearchPageNarrow.tsx
@@ -87,6 +87,7 @@ function SearchPageNarrow({queryJSON, headerButtonsOptions, searchResults, isMob
                 runOnJS(triggerScrollEvent)();
                 const {contentOffset, layoutMeasurement, contentSize} = event;
                 if (windowHeight > contentSize.height) {
+                    topBarOffset.set(StyleUtils.searchHeaderDefaultOffset);
                     return;
                 }
                 const currentOffset = contentOffset.y;
