Skip to content

Commit 7b65ac8

Browse files
luacmartinsOSBotify
authored andcommitted
Merge pull request #54060 from Expensify/revert-53740-fix/53286
Revert "Fix IOU amount input flicking" (cherry picked from commit 0a36b7b) (CP triggered by luacmartins)
1 parent 3c4bc00 commit 7b65ac8

File tree

8 files changed

+10
-27
lines changed

8 files changed

+10
-27
lines changed

src/components/AmountTextInput.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type AmountTextInputProps = {
3939

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

4444
function AmountTextInput(
4545
{

src/components/MoneyRequestAmountInput.tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import CONST from '@src/CONST';
1212
import isTextInputFocused from './TextInput/BaseTextInput/isTextInputFocused';
1313
import type {BaseTextInputRef} from './TextInput/BaseTextInput/types';
1414
import TextInputWithCurrencySymbol from './TextInputWithCurrencySymbol';
15-
import type {TextInputWithCurrencySymbolProps} from './TextInputWithCurrencySymbol/types';
1615

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

@@ -92,7 +91,7 @@ type MoneyRequestAmountInputProps = {
9291

9392
/** The width of inner content */
9493
contentWidth?: number;
95-
} & Pick<TextInputWithCurrencySymbolProps, 'autoGrowExtraSpace'>;
94+
};
9695

9796
type Selection = {
9897
start: number;
@@ -127,7 +126,6 @@ function MoneyRequestAmountInput(
127126
hideFocusedState = true,
128127
shouldKeepUserInput = false,
129128
autoGrow = true,
130-
autoGrowExtraSpace,
131129
contentWidth,
132130
...props
133131
}: MoneyRequestAmountInputProps,
@@ -291,7 +289,6 @@ function MoneyRequestAmountInput(
291289
return (
292290
<TextInputWithCurrencySymbol
293291
autoGrow={autoGrow}
294-
autoGrowExtraSpace={autoGrowExtraSpace}
295292
disableKeyboard={disableKeyboard}
296293
formattedAmount={formattedAmount}
297294
onChangeAmount={setNewAmount}

src/components/TextInput/BaseTextInput/index.native.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ function BaseTextInput(
4949
autoFocus = false,
5050
disableKeyboard = false,
5151
autoGrow = false,
52-
autoGrowExtraSpace = 0,
5352
autoGrowHeight = false,
5453
maxAutoGrowHeight,
5554
hideFocusedState = false,
@@ -251,8 +250,7 @@ function BaseTextInput(
251250
const newTextInputContainerStyles: StyleProp<ViewStyle> = StyleSheet.flatten([
252251
styles.textInputContainer,
253252
textInputContainerStyles,
254-
!!contentWidth && StyleUtils.getWidthStyle(textInputWidth),
255-
autoGrow && StyleUtils.getAutoGrowWidthInputContainerStyles(textInputWidth, autoGrowExtraSpace),
253+
(autoGrow || !!contentWidth) && StyleUtils.getWidthStyle(textInputWidth),
256254
!hideFocusedState && isFocused && styles.borderColorFocus,
257255
(!!hasError || !!errorText) && styles.borderColorDanger,
258256
autoGrowHeight && {scrollPaddingTop: typeof maxAutoGrowHeight === 'number' ? 2 * maxAutoGrowHeight : undefined},
@@ -443,10 +441,14 @@ function BaseTextInput(
443441
)}
444442
{/*
445443
Text input component doesn't support auto grow by default.
444+
We're using a hidden text input to achieve that.
446445
This text view is used to calculate width or height of the input value given textStyle in this component.
447446
This Text component is intentionally positioned out of the screen.
448447
*/}
449448
{(!!autoGrow || autoGrowHeight) && !isAutoGrowHeightMarkdown && (
449+
// Add +2 to width on Safari browsers so that text is not cut off due to the cursor or when changing the value
450+
// https://github.com/Expensify/App/issues/8158
451+
// https://github.com/Expensify/App/issues/26628
450452
<Text
451453
style={[
452454
inputStyle,

src/components/TextInput/BaseTextInput/index.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ function BaseTextInput(
5050
autoFocus = false,
5151
disableKeyboard = false,
5252
autoGrow = false,
53-
autoGrowExtraSpace = 0,
5453
autoGrowHeight = false,
5554
maxAutoGrowHeight,
5655
hideFocusedState = false,
@@ -251,8 +250,7 @@ function BaseTextInput(
251250
const newTextInputContainerStyles: StyleProp<ViewStyle> = StyleSheet.flatten([
252251
styles.textInputContainer,
253252
textInputContainerStyles,
254-
!!contentWidth && StyleUtils.getWidthStyle(textInputWidth),
255-
autoGrow && StyleUtils.getAutoGrowWidthInputContainerStyles(textInputWidth, autoGrowExtraSpace),
253+
(autoGrow || !!contentWidth) && StyleUtils.getWidthStyle(textInputWidth),
256254
!hideFocusedState && isFocused && styles.borderColorFocus,
257255
(!!hasError || !!errorText) && styles.borderColorDanger,
258256
autoGrowHeight && {scrollPaddingTop: typeof maxAutoGrowHeight === 'number' ? 2 * maxAutoGrowHeight : undefined},
@@ -488,6 +486,7 @@ function BaseTextInput(
488486
)}
489487
{/*
490488
Text input component doesn't support auto grow by default.
489+
We're using a hidden text input to achieve that.
491490
This text view is used to calculate width or height of the input value given textStyle in this component.
492491
This Text component is intentionally positioned out of the screen.
493492
*/}

src/components/TextInput/BaseTextInput/types.ts

-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ type CustomBaseTextInputProps = {
5454
*/
5555
autoGrow?: boolean;
5656

57-
/** If autoGrow is enabled, this reserves extra space for incoming characters to prevent flickering. */
58-
autoGrowExtraSpace?: number;
59-
6057
/**
6158
* Autogrow input container height based on the entered text
6259
*/

src/components/TextInputWithCurrencySymbol/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type BaseTextInputWithCurrencySymbolProps = {
7777

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

8282
type TextInputWithCurrencySymbolProps = Omit<BaseTextInputWithCurrencySymbolProps, 'onSelectionChange'> & {
8383
onSelectionChange?: (start: number, end: number) => void;

src/pages/iou/MoneyRequestAmountForm.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import * as CurrencyUtils from '@libs/CurrencyUtils';
1919
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
2020
import * as MoneyRequestUtils from '@libs/MoneyRequestUtils';
2121
import Navigation from '@libs/Navigation/Navigation';
22-
import variables from '@styles/variables';
2322
import type {BaseTextInputRef} from '@src/components/TextInput/BaseTextInput/types';
2423
import CONST from '@src/CONST';
2524
import type {Route} from '@src/ROUTES';
@@ -260,7 +259,6 @@ function MoneyRequestAmountForm(
260259
>
261260
<MoneyRequestAmountInput
262261
amount={amount}
263-
autoGrowExtraSpace={variables.w80}
264262
currency={currency}
265263
isCurrencyPressable={isCurrencyPressable}
266264
onCurrencyButtonPress={onCurrencyButtonPress}

src/styles/utils/index.ts

-10
Original file line numberDiff line numberDiff line change
@@ -1297,16 +1297,6 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({
12971297
};
12981298
},
12991299

1300-
/*
1301-
* Returns styles for the text input container, with extraSpace allowing overflow without affecting the layout.
1302-
*/
1303-
getAutoGrowWidthInputContainerStyles: (width: number, extraSpace: number): ViewStyle => {
1304-
if (!!width && !!extraSpace) {
1305-
return {marginRight: -extraSpace, width: width + extraSpace};
1306-
}
1307-
return {width};
1308-
},
1309-
13101300
/*
13111301
* Returns the actual maxHeight of the auto-growing markdown text input.
13121302
*/

0 commit comments

Comments
 (0)