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

[No QA] Revert "Merge pull request #35045 from callstack-internal/issues/30123" #42777

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ const onboardingChoices = {
type OnboardingPurposeType = ValueOf<typeof onboardingChoices>;

const CONST = {
RECENT_WAYPOINTS_NUMBER: 20,
DEFAULT_POLICY_ROOM_CHAT_TYPES: [chatTypes.POLICY_ADMINS, chatTypes.POLICY_ANNOUNCE, chatTypes.DOMAIN_ALL],

// Note: Group and Self-DM excluded as these are not tied to a Workspace
Expand Down
61 changes: 13 additions & 48 deletions src/components/AddressSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,7 @@ import CONST from '@src/CONST';
import type {Address} from '@src/types/onyx/PrivatePersonalDetails';
import CurrentLocationButton from './CurrentLocationButton';
import isCurrentTargetInsideContainer from './isCurrentTargetInsideContainer';
import listViewOverflow from './listViewOverflow';
import type {AddressSearchProps, PredefinedPlace} from './types';

/**
* Check if the place matches the search by the place name or description.
* @param search The search string for a place
* @param place The place to check for a match on the search
* @returns true if search is related to place, otherwise it returns false.
*/
function isPlaceMatchForSearch(search: string, place: PredefinedPlace): boolean {
if (!search) {
return true;
}
if (!place) {
return false;
}
const fullSearchSentence = `${place.name ?? ''} ${place.description}`;
return search.split(' ').every((searchTerm) => !searchTerm || (searchTerm && fullSearchSentence.toLocaleLowerCase().includes(searchTerm.toLocaleLowerCase())));
}
import type {AddressSearchProps} from './types';

// The error that's being thrown below will be ignored until we fork the
// react-native-google-places-autocomplete repo and replace the
Expand All @@ -59,7 +41,6 @@ function AddressSearch(
isLimitedToUSA = false,
label,
maxInputLength,
onFocus,
onBlur,
onInputChange,
onPress,
Expand Down Expand Up @@ -317,16 +298,10 @@ function AddressSearch(
};
}, []);

const filteredPredefinedPlaces = useMemo(() => {
if (!isOffline || !searchValue) {
return predefinedPlaces ?? [];
}
return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? [];
}, [isOffline, predefinedPlaces, searchValue]);

const listEmptyComponent = useCallback(
() => (!isTyping ? null : <Text style={[styles.textLabel, styles.colorMuted, styles.pv4, styles.ph3, styles.overflowAuto]}>{translate('common.noResultsFound')}</Text>),
[isTyping, styles, translate],
() =>
!!isOffline || !isTyping ? null : <Text style={[styles.textLabel, styles.colorMuted, styles.pv4, styles.ph3, styles.overflowAuto]}>{translate('common.noResultsFound')}</Text>,
[isOffline, isTyping, styles, translate],
);

const listLoader = useCallback(
Expand Down Expand Up @@ -363,10 +338,11 @@ function AddressSearch(
ref={containerRef}
>
<GooglePlacesAutocomplete
disableScroll
fetchDetails
suppressDefaultStyles
enablePoweredByContainer={false}
predefinedPlaces={filteredPredefinedPlaces}
predefinedPlaces={predefinedPlaces ?? undefined}
listEmptyComponent={listEmptyComponent}
listLoaderComponent={listLoader}
renderHeaderComponent={renderHeaderComponent}
Expand All @@ -375,7 +351,7 @@ function AddressSearch(
const subtitle = data.isPredefinedPlace ? data.description : data.structured_formatting.secondary_text;
return (
<View>
{!!title && <Text style={styles.googleSearchText}>{title}</Text>}
{!!title && <Text style={[styles.googleSearchText]}>{title}</Text>}
<Text style={[title ? styles.textLabelSupporting : styles.googleSearchText]}>{subtitle}</Text>
</View>
);
Expand Down Expand Up @@ -409,7 +385,6 @@ function AddressSearch(
shouldSaveDraft,
onFocus: () => {
setIsFocused(true);
onFocus?.();
},
onBlur: (event) => {
if (!isCurrentTargetInsideContainer(event, containerRef)) {
Expand Down Expand Up @@ -439,18 +414,10 @@ function AddressSearch(
}}
styles={{
textInputContainer: [styles.flexColumn],
listView: [
StyleUtils.getGoogleListViewStyle(displayListViewBorder),
listViewOverflow,
styles.borderLeft,
styles.borderRight,
styles.flexGrow0,
!isFocused && styles.h0,
],
listView: [StyleUtils.getGoogleListViewStyle(displayListViewBorder), styles.overflowAuto, styles.borderLeft, styles.borderRight, !isFocused && {height: 0}],
row: [styles.pv4, styles.ph3, styles.overflowAuto],
description: [styles.googleSearchText],
separator: [styles.googleSearchSeparator],
container: [styles.mh100],
}}
numberOfLines={2}
isRowScrollable={false}
Expand All @@ -474,13 +441,11 @@ function AddressSearch(
)
}
placeholder=""
listViewDisplayed
>
<LocationErrorMessage
onClose={() => setLocationErrorCode(null)}
locationErrorCode={locationErrorCode}
/>
</GooglePlacesAutocomplete>
/>
<LocationErrorMessage
onClose={() => setLocationErrorCode(null)}
locationErrorCode={locationErrorCode}
/>
</View>
</ScrollView>
{isFetchingCurrentLocation && <FullScreenLoadingIndicator />}
Expand Down

This file was deleted.

4 changes: 0 additions & 4 deletions src/components/AddressSearch/listViewOverflow/index.ts

This file was deleted.

11 changes: 2 additions & 9 deletions src/components/AddressSearch/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,13 @@ type StreetValue = {
street: string;
};

type PredefinedPlace = Place & {
name?: string;
};

type AddressSearchProps = {
/** The ID used to uniquely identify the input in a Form */
inputID?: string;

/** Saves a draft of the input value when used in a form */
shouldSaveDraft?: boolean;

/** Callback that is called when the text input is focused */
onFocus?: () => void;

/** Callback that is called when the text input is blurred */
onBlur?: () => void;

Expand Down Expand Up @@ -72,7 +65,7 @@ type AddressSearchProps = {
canUseCurrentLocation?: boolean;

/** A list of predefined places that can be shown when the user isn't searching for something */
predefinedPlaces?: PredefinedPlace[] | null;
predefinedPlaces?: Place[] | null;

/** A map of inputID key names */
renamedInputKeys?: Address;
Expand All @@ -92,4 +85,4 @@ type AddressSearchProps = {

type IsCurrentTargetInsideContainerType = (event: FocusEvent | NativeSyntheticEvent<TextInputFocusEventData>, containerRef: RefObject<View | HTMLElement>) => boolean;

export type {CurrentLocationButtonProps, AddressSearchProps, IsCurrentTargetInsideContainerType, StreetValue, PredefinedPlace};
export type {CurrentLocationButtonProps, AddressSearchProps, IsCurrentTargetInsideContainerType, StreetValue};
3 changes: 0 additions & 3 deletions src/components/Form/FormProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ type FormProviderProps<TFormID extends OnyxFormKey = OnyxFormKey> = FormProvider

/** Whether to apply flex to the submit button */
submitFlexEnabled?: boolean;

/** Whether the form container should grow or adapt to the viewable available space */
shouldContainerGrow?: boolean;
};

function FormProvider(
Expand Down
14 changes: 5 additions & 9 deletions src/components/Form/FormWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useCallback, useMemo, useRef} from 'react';
import type {RefObject} from 'react';
// eslint-disable-next-line no-restricted-imports
import type {ScrollView as RNScrollView, StyleProp, ViewStyle} from 'react-native';
import {Keyboard, View} from 'react-native';
import type {ScrollView as RNScrollView, StyleProp, View, ViewStyle} from 'react-native';
import {Keyboard} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import FormAlertWithSubmitButton from '@components/FormAlertWithSubmitButton';
Expand Down Expand Up @@ -32,9 +32,6 @@ type FormWrapperProps = ChildrenProps &
/** Whether to apply flex to the submit button */
submitFlexEnabled?: boolean;

/** Whether the form container should grow or adapt to the viewable available space */
shouldContainerGrow?: boolean;

/** Server side errors keyed by microtime */
errors: FormInputErrors;

Expand Down Expand Up @@ -63,7 +60,6 @@ function FormWrapper({
scrollContextEnabled = false,
shouldHideFixErrorsAlert = false,
disablePressOnEnter = true,
shouldContainerGrow = true,
}: FormWrapperProps) {
const styles = useThemeStyles();
const formRef = useRef<RNScrollView>(null);
Expand Down Expand Up @@ -108,7 +104,7 @@ function FormWrapper({
ref={formContentRef}
style={[style, safeAreaPaddingBottomStyle.paddingBottom ? safeAreaPaddingBottomStyle : styles.pb5]}
>
<View style={styles.flex1}>{children}</View>
{children}
{isSubmitButtonVisible && (
<FormAlertWithSubmitButton
buttonText={submitButtonText}
Expand Down Expand Up @@ -159,7 +155,7 @@ function FormWrapper({
scrollContextEnabled ? (
<ScrollViewWithContext
style={[styles.w100, styles.flex1]}
contentContainerStyle={shouldContainerGrow ? styles.flexGrow1 : styles.flex1}
contentContainerStyle={styles.flexGrow1}
keyboardShouldPersistTaps="handled"
ref={formRef}
>
Expand All @@ -168,7 +164,7 @@ function FormWrapper({
) : (
<ScrollView
style={[styles.w100, styles.flex1]}
contentContainerStyle={shouldContainerGrow ? styles.flexGrow1 : styles.flex1}
contentContainerStyle={styles.flexGrow1}
keyboardShouldPersistTaps="handled"
ref={formRef}
>
Expand Down
33 changes: 0 additions & 33 deletions src/hooks/useSubmitButtonVisibility.native.ts

This file was deleted.

58 changes: 0 additions & 58 deletions src/hooks/useSubmitButtonVisibility.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/libs/actions/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function saveWaypoint(transactionID: string, index: string, waypoint: RecentWayp
if (!recentWaypointAlreadyExists && waypoint !== null) {
const clonedWaypoints = lodashClone(recentWaypoints);
clonedWaypoints.unshift(waypoint);
Onyx.merge(ONYXKEYS.NVP_RECENT_WAYPOINTS, clonedWaypoints.slice(0, CONST.RECENT_WAYPOINTS_NUMBER));
Onyx.merge(ONYXKEYS.NVP_RECENT_WAYPOINTS, clonedWaypoints.slice(0, 5));
}
}

Expand Down
Loading
Loading