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

Revert "Fix IOU amount input flicking" #54060

Merged
merged 1 commit into from
Dec 12, 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
2 changes: 1 addition & 1 deletion src/components/AmountTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type AmountTextInputProps = {

/** Hide the focus styles on TextInput */
hideFocusedState?: boolean;
} & Pick<BaseTextInputProps, 'autoFocus' | 'autoGrowExtraSpace'>;
} & Pick<BaseTextInputProps, 'autoFocus'>;

function AmountTextInput(
{
Expand Down
5 changes: 1 addition & 4 deletions src/components/MoneyRequestAmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import CONST from '@src/CONST';
import isTextInputFocused from './TextInput/BaseTextInput/isTextInputFocused';
import type {BaseTextInputRef} from './TextInput/BaseTextInput/types';
import TextInputWithCurrencySymbol from './TextInputWithCurrencySymbol';
import type {TextInputWithCurrencySymbolProps} from './TextInputWithCurrencySymbol/types';

type CurrentMoney = {amount: string; currency: string};

Expand Down Expand Up @@ -92,7 +91,7 @@ type MoneyRequestAmountInputProps = {

/** The width of inner content */
contentWidth?: number;
} & Pick<TextInputWithCurrencySymbolProps, 'autoGrowExtraSpace'>;
};

type Selection = {
start: number;
Expand Down Expand Up @@ -127,7 +126,6 @@ function MoneyRequestAmountInput(
hideFocusedState = true,
shouldKeepUserInput = false,
autoGrow = true,
autoGrowExtraSpace,
contentWidth,
...props
}: MoneyRequestAmountInputProps,
Expand Down Expand Up @@ -291,7 +289,6 @@ function MoneyRequestAmountInput(
return (
<TextInputWithCurrencySymbol
autoGrow={autoGrow}
autoGrowExtraSpace={autoGrowExtraSpace}
disableKeyboard={disableKeyboard}
formattedAmount={formattedAmount}
onChangeAmount={setNewAmount}
Expand Down
8 changes: 5 additions & 3 deletions src/components/TextInput/BaseTextInput/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ function BaseTextInput(
autoFocus = false,
disableKeyboard = false,
autoGrow = false,
autoGrowExtraSpace = 0,
autoGrowHeight = false,
maxAutoGrowHeight,
hideFocusedState = false,
Expand Down Expand Up @@ -251,8 +250,7 @@ function BaseTextInput(
const newTextInputContainerStyles: StyleProp<ViewStyle> = StyleSheet.flatten([
styles.textInputContainer,
textInputContainerStyles,
!!contentWidth && StyleUtils.getWidthStyle(textInputWidth),
autoGrow && StyleUtils.getAutoGrowWidthInputContainerStyles(textInputWidth, autoGrowExtraSpace),
(autoGrow || !!contentWidth) && StyleUtils.getWidthStyle(textInputWidth),
!hideFocusedState && isFocused && styles.borderColorFocus,
(!!hasError || !!errorText) && styles.borderColorDanger,
autoGrowHeight && {scrollPaddingTop: typeof maxAutoGrowHeight === 'number' ? 2 * maxAutoGrowHeight : undefined},
Expand Down Expand Up @@ -443,10 +441,14 @@ function BaseTextInput(
)}
{/*
Text input component doesn't support auto grow by default.
We're using a hidden text input to achieve that.
This text view is used to calculate width or height of the input value given textStyle in this component.
This Text component is intentionally positioned out of the screen.
*/}
{(!!autoGrow || autoGrowHeight) && !isAutoGrowHeightMarkdown && (
// Add +2 to width on Safari browsers so that text is not cut off due to the cursor or when changing the value
// https://github.com/Expensify/App/issues/8158
// https://github.com/Expensify/App/issues/26628
<Text
style={[
inputStyle,
Expand Down
5 changes: 2 additions & 3 deletions src/components/TextInput/BaseTextInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ function BaseTextInput(
autoFocus = false,
disableKeyboard = false,
autoGrow = false,
autoGrowExtraSpace = 0,
autoGrowHeight = false,
maxAutoGrowHeight,
hideFocusedState = false,
Expand Down Expand Up @@ -251,8 +250,7 @@ function BaseTextInput(
const newTextInputContainerStyles: StyleProp<ViewStyle> = StyleSheet.flatten([
styles.textInputContainer,
textInputContainerStyles,
!!contentWidth && StyleUtils.getWidthStyle(textInputWidth),
autoGrow && StyleUtils.getAutoGrowWidthInputContainerStyles(textInputWidth, autoGrowExtraSpace),
(autoGrow || !!contentWidth) && StyleUtils.getWidthStyle(textInputWidth),
!hideFocusedState && isFocused && styles.borderColorFocus,
(!!hasError || !!errorText) && styles.borderColorDanger,
autoGrowHeight && {scrollPaddingTop: typeof maxAutoGrowHeight === 'number' ? 2 * maxAutoGrowHeight : undefined},
Expand Down Expand Up @@ -488,6 +486,7 @@ function BaseTextInput(
)}
{/*
Text input component doesn't support auto grow by default.
We're using a hidden text input to achieve that.
This text view is used to calculate width or height of the input value given textStyle in this component.
This Text component is intentionally positioned out of the screen.
*/}
Expand Down
3 changes: 0 additions & 3 deletions src/components/TextInput/BaseTextInput/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ type CustomBaseTextInputProps = {
*/
autoGrow?: boolean;

/** If autoGrow is enabled, this reserves extra space for incoming characters to prevent flickering. */
autoGrowExtraSpace?: number;

/**
* Autogrow input container height based on the entered text
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextInputWithCurrencySymbol/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type BaseTextInputWithCurrencySymbolProps = {

/** Hide the focus styles on TextInput */
hideFocusedState?: boolean;
} & Pick<BaseTextInputProps, 'autoFocus' | 'autoGrow' | 'autoGrowExtraSpace' | 'contentWidth' | 'onPress'>;
} & Pick<BaseTextInputProps, 'autoFocus' | 'autoGrow' | 'contentWidth' | 'onPress'>;

type TextInputWithCurrencySymbolProps = Omit<BaseTextInputWithCurrencySymbolProps, 'onSelectionChange'> & {
onSelectionChange?: (start: number, end: number) => void;
Expand Down
2 changes: 0 additions & 2 deletions src/pages/iou/MoneyRequestAmountForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import * as CurrencyUtils from '@libs/CurrencyUtils';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import * as MoneyRequestUtils from '@libs/MoneyRequestUtils';
import Navigation from '@libs/Navigation/Navigation';
import variables from '@styles/variables';
import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types';
import CONST from '@src/CONST';
import type {Route} from '@src/ROUTES';
Expand Down Expand Up @@ -260,7 +259,6 @@ function MoneyRequestAmountForm(
>
<MoneyRequestAmountInput
amount={amount}
autoGrowExtraSpace={variables.w80}
currency={currency}
isCurrencyPressable={isCurrencyPressable}
onCurrencyButtonPress={onCurrencyButtonPress}
Expand Down
10 changes: 0 additions & 10 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1297,16 +1297,6 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({
};
},

/*
* Returns styles for the text input container, with extraSpace allowing overflow without affecting the layout.
*/
getAutoGrowWidthInputContainerStyles: (width: number, extraSpace: number): ViewStyle => {
if (!!width && !!extraSpace) {
return {marginRight: -extraSpace, width: width + extraSpace};
}
return {width};
},

/*
* Returns the actual maxHeight of the auto-growing markdown text input.
*/
Expand Down
Loading