Skip to content

fix Lottie Animation Scaling and container width in Trips Empty State Illustration #61996

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
8 changes: 4 additions & 4 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useMemo, useRef, useState} from 'react';
// eslint-disable-next-line no-restricted-imports
import type {GestureResponderEvent, Text as RNText} from 'react-native';
import type {GestureResponderEvent, ImageStyle, Text as RNText, ViewStyle} from 'react-native';
import {Linking, View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import type {OnyxCollection} from 'react-native-onyx';
Expand Down Expand Up @@ -144,11 +144,11 @@ function EmptySearchView({type, hasResults}: EmptySearchViewProps) {
case CONST.SEARCH.DATA_TYPES.TRIP:
return {
headerMedia: LottieAnimations.TripsEmptyState,
headerContentStyles: [StyleUtils.getWidthAndHeightStyle(375, 240), StyleUtils.getBackgroundColorStyle(theme.travelBG)],
headerContentStyles: [styles.emptyStateFolderWebStyles, StyleUtils.getBackgroundColorStyle(theme.travelBG)],
title: translate('travel.title'),
titleStyles: {...styles.textAlignLeft},
children: tripViewChildren,
lottieWebViewStyles: {backgroundColor: theme.travelBG, ...styles.emptyStateFolderWebStyles},
lottieWebViewStyles: {backgroundColor: theme.travelBG, ...styles.emptyStateFolderWebStyles, width: 335, height: 220},
};
case CONST.SEARCH.DATA_TYPES.EXPENSE:
if (!hasResults) {
Expand Down Expand Up @@ -272,7 +272,7 @@ function EmptySearchView({type, hasResults}: EmptySearchViewProps) {
titleStyles={content.titleStyles}
subtitle={content.subtitle}
buttons={content.buttons}
headerContentStyles={[styles.h100, styles.w100, ...content.headerContentStyles]}
headerContentStyles={[styles.h100, styles.w100, ...content.headerContentStyles] as Array<ViewStyle & ImageStyle>}
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this change , I don't think it's needed here.

Copy link
Contributor Author

@nabi-ebrahimi nabi-ebrahimi May 15, 2025

Choose a reason for hiding this comment

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

I need to either update the type of the headerContentStyles prop or leave it as is, since removing it leads to a type error.

Currently, its type is ViewStyle & ImageStyle in the EmptyStateComponent, so we’d also need to update the types in EmptyStateComponent accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the styling is consistent across other headerContentStyles, why is CONST.SEARCH.DATA_TYPES.TRIP the only one throwing a type error?

Copy link
Contributor Author

@nabi-ebrahimi nabi-ebrahimi May 16, 2025

Choose a reason for hiding this comment

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

Other cases in the switch include !hasResults, which hinders TypeScript's ability to infer types accurately.

For example, returning this value in the first case causes type errors that are handled correctly in the default case.

  return {
                    headerMedia: LottieAnimations.GenericEmptyState,
                    title: translate('search.searchResults.emptyResults.title'),
                    subtitle: translate('search.searchResults.emptyResults.subtitle'),
                    headerContentStyles: [styles.emptyStateFolderWebStyles, StyleUtils.getBackgroundColorStyle(theme.emptyFolderBG)],
                    lottieWebViewStyles: {backgroundColor: theme.emptyFolderBG, ...styles.emptyStateFolderWebStyles},
                };

lottieWebViewStyles={content.lottieWebViewStyles}
>
{content.children}
Expand Down
Loading