Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e2f4dda
fix: Android & iOS - Text is cut off in the search field when device …
Krishna2323 Jun 27, 2025
693f6ac
Merge branch 'Expensify:main' into krishna2323/issue/62907
Krishna2323 Jun 30, 2025
b8c80e3
fix input alignment.
Krishna2323 Jun 30, 2025
4373ddd
fix multiline input.
Krishna2323 Jul 1, 2025
936a8f8
fix prefix and suffix characters alignment.
Krishna2323 Jul 1, 2025
2db860c
Merge branch 'Expensify:main' into krishna2323/issue/62907
Krishna2323 Jul 4, 2025
a2fda2b
add prop for using default line height for prefix character.
Krishna2323 Jul 4, 2025
7ea2a16
Merge branch 'Expensify:main' into krishna2323/issue/62907
Krishna2323 Jul 11, 2025
b7fbb0b
Merge branch 'Expensify:main' into krishna2323/issue/62907
Krishna2323 Jul 14, 2025
69989a3
Merge branch 'Expensify:main' into krishna2323/issue/62907
Krishna2323 Jul 16, 2025
da4df37
fix prop name, icon alignment, and comment.
Krishna2323 Jul 16, 2025
d4d9361
fix ESLint.
Krishna2323 Jul 16, 2025
9350c86
Merge branch 'Expensify:main' into krishna2323/issue/62907
Krishna2323 Jul 21, 2025
9b59c60
Merge branch 'Expensify:main' into krishna2323/issue/62907
Krishna2323 Jul 25, 2025
2b72873
fix tax amount picker alignment.
Krishna2323 Jul 25, 2025
677bdda
Merge branch 'Expensify:main' into krishna2323/issue/62907
Krishna2323 Jul 28, 2025
c20b236
fix input icon alignment.
Krishna2323 Jul 28, 2025
8273b1e
fix activity indicator alignment.
Krishna2323 Jul 28, 2025
2447260
centre icon based on input vertical padding diff.
Krishna2323 Jul 29, 2025
01181e7
fix spell check.
Krishna2323 Jul 29, 2025
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
4 changes: 2 additions & 2 deletions src/components/CurrencySymbolButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ function CurrencySymbolButton({onCurrencyButtonPress, currencySymbol, isCurrency
src={Expensicons.DownArrow}
fill={theme.icon}
/>
<Text style={styles.iouAmountText}>{currencySymbol}</Text>
<Text style={[styles.iouAmountText, styles.lineHeightUndefined]}>{currencySymbol}</Text>
</PressableWithoutFeedback>
</Tooltip>
) : (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.gap1]}>
<Text style={styles.iouAmountText}>{currencySymbol}</Text>
<Text style={[styles.iouAmountText, styles.lineHeightUndefined]}>{currencySymbol}</Text>
</View>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/components/MoneyRequestAmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type MoneyRequestAmountInputProps = {

/** The testID of the input. Used to locate this view in end-to-end tests. */
testID?: string;
} & Pick<TextInputWithCurrencySymbolProps, 'autoGrowExtraSpace' | 'submitBehavior'>;
} & Pick<TextInputWithCurrencySymbolProps, 'autoGrowExtraSpace' | 'submitBehavior' | 'shouldUseDefaultLineHeightForPrefix'>;

type Selection = {
start: number;
Expand Down Expand Up @@ -136,6 +136,7 @@ function MoneyRequestAmountInput(
testID,
submitBehavior,
shouldApplyPaddingToContainer = false,
shouldUseDefaultLineHeightForPrefix = true,
...props
}: MoneyRequestAmountInputProps,
forwardedRef: ForwardedRef<BaseTextInputRef>,
Expand Down Expand Up @@ -348,6 +349,7 @@ function MoneyRequestAmountInput(
testID={testID}
submitBehavior={submitBehavior}
shouldApplyPaddingToContainer={shouldApplyPaddingToContainer}
shouldUseDefaultLineHeightForPrefix={shouldUseDefaultLineHeightForPrefix}
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ function MoneyRequestConfirmationList({
maxLength={formattedTotalAmount.length + 1}
contentWidth={(formattedTotalAmount.length + 1) * 8}
shouldApplyPaddingToContainer
shouldUseDefaultLineHeightForPrefix={false}
/>
),
}));
Expand Down
1 change: 1 addition & 0 deletions src/components/SelectionList/SplitListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function SplitListItem<TItem extends ListItem>({
maxLength={formattedOriginalAmount.length + 1}
contentWidth={(formattedOriginalAmount.length + 1) * 8}
shouldApplyPaddingToContainer
shouldUseDefaultLineHeightForPrefix={false}
/>
</View>
<View style={[styles.popoverMenuIcon, styles.pointerEventsAuto]}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function BaseTextInput(
placeholderTextColor,
onClearInput,
iconContainerStyle,
shouldUseDefaultLineHeightForPrefix = true,
...props
}: BaseTextInputProps,
ref: ForwardedRef<BaseTextInputRef>,
Expand Down Expand Up @@ -275,6 +276,7 @@ function BaseTextInput(
shouldAddPaddingBottom && styles.pb1,
]);

const verticalPaddingDiff = StyleUtils.getVerticalPaddingDiffFromStyle(newTextInputContainerStyles);
const inputPaddingLeft = !!prefixCharacter && StyleUtils.getPaddingLeft(prefixCharacterPadding + styles.pl1.paddingLeft);
const inputPaddingRight = !!suffixCharacter && StyleUtils.getPaddingRight(StyleUtils.getCharacterPadding(suffixCharacter) + styles.pr1.paddingRight);

Expand All @@ -300,7 +302,7 @@ function BaseTextInput(
variables.componentSizeLarge,
typeof maxAutoGrowHeight === 'number' ? maxAutoGrowHeight : 0,
),
isAutoGrowHeightMarkdown && {minHeight: variables.componentSizeLarge},
isAutoGrowHeightMarkdown && {minHeight: variables.inputHeight},
!isMultiline && styles.componentHeightLarge,
touchableInputWrapperStyle,
]}
Expand Down Expand Up @@ -346,7 +348,7 @@ function BaseTextInput(
</View>
)}
{!!prefixCharacter && (
<View style={[styles.textInputPrefixWrapper, prefixContainerStyle]}>
<View style={[styles.textInputPrefixWrapper, prefixContainerStyle, shouldApplyHeight && {height}]}>
<Text
onLayout={(event) => {
if (event.nativeEvent.layout.width === 0 && event.nativeEvent.layout.height === 0) {
Expand All @@ -358,6 +360,7 @@ function BaseTextInput(
tabIndex={-1}
style={[styles.textInputPrefix, !hasLabel && styles.pv0, styles.pointerEventsNone, prefixStyle]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
shouldUseDefaultLineHeight={!!shouldUseDefaultLineHeightForPrefix && !shouldApplyHeight}
>
{prefixCharacter}
</Text>
Expand Down Expand Up @@ -431,7 +434,7 @@ function BaseTextInput(
)}
{((isFocused && !isReadOnly && shouldShowClearButton) || !shouldHideClearButton) && !!value && (
<TextInputClearButton
style={StyleUtils.getTextInputIconContainerStyles(hasLabel, false)}
style={StyleUtils.getTextInputIconContainerStyles(hasLabel, false, verticalPaddingDiff)}
onPressButton={() => {
setValue('');
onClearInput?.();
Expand All @@ -443,17 +446,16 @@ function BaseTextInput(
size="small"
color={theme.iconSuccessFill}
style={[
StyleUtils.getTextInputIconContainerStyles(hasLabel, false),
StyleUtils.getTextInputIconContainerStyles(hasLabel, false, verticalPaddingDiff),
styles.ml1,
styles.justifyContentStart,
loadingSpinnerStyle,
StyleUtils.getOpacityStyle(inputProps.isLoading ? 1 : 0),
]}
/>
)}
{!!inputProps.secureTextEntry && (
<Checkbox
style={StyleUtils.getTextInputIconContainerStyles(hasLabel)}
style={StyleUtils.getTextInputIconContainerStyles(hasLabel, true, verticalPaddingDiff)}
onPress={togglePasswordVisibility}
onMouseDown={(event) => {
event.preventDefault();
Expand All @@ -467,7 +469,13 @@ function BaseTextInput(
</Checkbox>
)}
{!inputProps.secureTextEntry && !!icon && (
<View style={[StyleUtils.getTextInputIconContainerStyles(hasLabel), !isReadOnly ? styles.cursorPointer : styles.pointerEventsNone, iconContainerStyle]}>
<View
style={[
StyleUtils.getTextInputIconContainerStyles(hasLabel, true, verticalPaddingDiff),
!isReadOnly ? styles.cursorPointer : styles.pointerEventsNone,
iconContainerStyle,
]}
>
<Icon
src={icon}
fill={theme.icon}
Expand Down
20 changes: 13 additions & 7 deletions src/components/TextInput/BaseTextInput/implementation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function BaseTextInput(
placeholderTextColor,
onClearInput,
iconContainerStyle,
shouldUseDefaultLineHeightForPrefix = true,
...inputProps
}: BaseTextInputProps,
ref: ForwardedRef<BaseTextInputRef>,
Expand Down Expand Up @@ -280,12 +281,12 @@ function BaseTextInput(
shouldAddPaddingBottom && styles.pb1,
]);

const verticalPaddingDiff = StyleUtils.getVerticalPaddingDiffFromStyle(newTextInputContainerStyles);
const inputPaddingLeft = !!prefixCharacter && StyleUtils.getPaddingLeft(prefixCharacterPadding + styles.pl1.paddingLeft);
const inputPaddingRight = !!suffixCharacter && StyleUtils.getPaddingRight(StyleUtils.getCharacterPadding(suffixCharacter) + styles.pr1.paddingRight);
// This is workaround for https://github.com/Expensify/App/issues/47939: in case when user is using Chrome on Android we set inputMode to 'search' to disable autocomplete bar above the keyboard.
// If we need some other inputMode (eg. 'decimal'), then the autocomplete bar will show, but we can do nothing about it as it's a known Chrome bug.
const inputMode = inputProps.inputMode ?? (isMobileChrome() ? 'search' : undefined);

return (
<>
<View
Expand Down Expand Up @@ -368,7 +369,7 @@ function BaseTextInput(
tabIndex={-1}
style={[styles.textInputPrefix, !hasLabel && styles.pv0, styles.pointerEventsNone, prefixStyle]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
shouldUseDefaultLineHeight={!Object.keys(StyleSheet.flatten(prefixStyle)).includes('lineHeight')}
shouldUseDefaultLineHeight={shouldUseDefaultLineHeightForPrefix}
>
{prefixCharacter}
</Text>
Expand Down Expand Up @@ -453,7 +454,7 @@ function BaseTextInput(
}}
>
<TextInputClearButton
style={StyleUtils.getTextInputIconContainerStyles(hasLabel, false)}
style={StyleUtils.getTextInputIconContainerStyles(hasLabel, false, verticalPaddingDiff)}
onPressButton={() => {
setValue('');
onClearInput?.();
Expand All @@ -466,17 +467,16 @@ function BaseTextInput(
size="small"
color={theme.iconSuccessFill}
style={[
StyleUtils.getTextInputIconContainerStyles(hasLabel, false),
StyleUtils.getTextInputIconContainerStyles(hasLabel, false, verticalPaddingDiff),
styles.ml1,
styles.justifyContentStart,
loadingSpinnerStyle,
StyleUtils.getOpacityStyle(inputProps.isLoading ? 1 : 0),
]}
/>
)}
{!!inputProps.secureTextEntry && (
<Checkbox
style={StyleUtils.getTextInputIconContainerStyles(hasLabel)}
style={StyleUtils.getTextInputIconContainerStyles(hasLabel, true, verticalPaddingDiff)}
onPress={togglePasswordVisibility}
onMouseDown={(e) => {
e.preventDefault();
Expand All @@ -490,7 +490,13 @@ function BaseTextInput(
</Checkbox>
)}
{!inputProps.secureTextEntry && !!icon && (
<View style={[StyleUtils.getTextInputIconContainerStyles(hasLabel), !isReadOnly ? styles.cursorPointer : styles.pointerEventsNone, iconContainerStyle]}>
<View
style={[
StyleUtils.getTextInputIconContainerStyles(hasLabel, true, verticalPaddingDiff),
!isReadOnly ? styles.cursorPointer : styles.pointerEventsNone,
iconContainerStyle,
]}
>
<Icon
src={icon}
fill={theme.icon}
Expand Down
3 changes: 3 additions & 0 deletions src/components/TextInput/BaseTextInput/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ type CustomBaseTextInputProps = {

/** Whether the input should be enforced to take full height of container. Default is `false` */
shouldUseFullInputHeight?: boolean;

/** Whether the input prefix should use the default `Text` line height fallback. Disable this if you intentionally want the prefix to have `lineHeight: undefined` */
shouldUseDefaultLineHeightForPrefix?: boolean;
};

type BaseTextInputRef = HTMLFormElement | AnimatedTextInputRef;
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 @@ -83,7 +83,7 @@ type BaseTextInputWithCurrencySymbolProps = {

/** The test ID of TextInput. Used to locate the view in end-to-end tests. */
testID?: string;
} & Pick<BaseTextInputProps, 'autoFocus' | 'autoGrow' | 'autoGrowExtraSpace' | 'contentWidth' | 'onPress' | 'submitBehavior'>;
} & Pick<BaseTextInputProps, 'autoFocus' | 'autoGrow' | 'autoGrowExtraSpace' | 'contentWidth' | 'onPress' | 'submitBehavior' | 'shouldUseDefaultLineHeightForPrefix'>;

type TextInputWithCurrencySymbolProps = Omit<BaseTextInputWithCurrencySymbolProps, 'onSelectionChange'> & {
onSelectionChange?: (start: number, end: number) => void;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/taxes/ValuePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function ValuePage({
extraDecimals={CONST.MAX_TAX_RATE_DECIMAL_PLACES - 2}
// We increase the amount max length to support the extra decimals.
amountMaxLength={CONST.MAX_TAX_RATE_INTEGER_PLACES}
extraSymbol={<Text style={styles.iouAmountText}>%</Text>}
extraSymbol={<Text style={[styles.iouAmountText, styles.lineHeightUndefined]}>%</Text>}
ref={inputCallbackRef}
autoGrowExtraSpace={variables.w80}
autoGrowMarginSide="left"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/workspace/taxes/WorkspaceCreateTaxPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function WorkspaceCreateTaxPage({
extraDecimals={CONST.MAX_TAX_RATE_DECIMAL_PLACES - 2}
// We increase the amount max length to support the extra decimals.
amountMaxLength={CONST.MAX_TAX_RATE_INTEGER_PLACES}
extraSymbol={<Text style={styles.iouAmountText}>%</Text>}
extraSymbol={<Text style={[styles.iouAmountText, styles.lineHeightUndefined]}>%</Text>}
autoGrowExtraSpace={variables.w80}
autoGrowMarginSide="left"
style={[styles.iouAmountTextInput, styles.textAlignRight]}
Expand Down
14 changes: 7 additions & 7 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1317,8 +1317,8 @@ const styles = (theme: ThemeColors) =>
fontSize: variables.fontSizeNormal,
lineHeight: variables.lineHeightXLarge,
color: theme.text,
paddingTop: 15,
paddingBottom: 8,
paddingTop: variables.inputPaddingTop,
paddingBottom: variables.inputPaddingBottom,
paddingLeft: 0,
borderWidth: 0,
},
Expand All @@ -1329,7 +1329,7 @@ const styles = (theme: ThemeColors) =>

textInputMultilineContainer: {
height: '100%',
paddingTop: 15,
paddingTop: variables.inputPaddingTop,
},

textInputAndIconContainer: (isMarkdownEnabled: boolean) => {
Expand Down Expand Up @@ -1378,8 +1378,8 @@ const styles = (theme: ThemeColors) =>
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
paddingTop: 15,
paddingBottom: 8,
paddingTop: variables.inputPaddingTop,
paddingBottom: variables.inputPaddingBottom,
height: '100%',
},

Expand All @@ -1390,8 +1390,8 @@ const styles = (theme: ThemeColors) =>
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
paddingTop: 15,
paddingBottom: 8,
paddingTop: variables.inputPaddingTop,
paddingBottom: variables.inputPaddingBottom,
},

textInputPrefix: {
Expand Down
28 changes: 24 additions & 4 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {StyleSheet} from 'react-native';
import type {AnimatableNumericValue, ColorValue, ImageStyle, PressableStateCallbackType, StyleProp, TextStyle, ViewStyle} from 'react-native';
// eslint-disable-next-line no-restricted-imports
import type {AnimatableNumericValue, Animated, ColorValue, ImageStyle, PressableStateCallbackType, StyleProp, TextStyle, ViewStyle} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import type {EdgeInsets} from 'react-native-safe-area-context';
import type {ValueOf} from 'type-fest';
Expand Down Expand Up @@ -727,6 +728,22 @@ function getPaddingBottom(paddingBottom: number): ViewStyle {
};
}

/**
* Get vertical padding diff from provided styles (paddingTop - paddingBottom)
*/
function getVerticalPaddingDiffFromStyle(textInputContainerStyles: ViewStyle): number {
const flatStyle = StyleSheet.flatten(textInputContainerStyles);

// Safely extract padding values only if they are numbers
const getNumericPadding = (paddingValue: string | number | Animated.AnimatedNode | null | undefined): number => {
return typeof paddingValue === 'number' ? paddingValue : 0;
};

const paddingTop = getNumericPadding(flatStyle?.paddingTop ?? flatStyle.padding);
const paddingBottom = getNumericPadding(flatStyle?.paddingBottom ?? flatStyle.padding);
return paddingTop - paddingBottom;
}

/**
* Checks to see if the iOS device has safe areas or not
*/
Expand Down Expand Up @@ -1237,6 +1254,7 @@ const staticStyleUtils = {
getPaddingLeft,
getPaddingRight,
getPaddingBottom,
getVerticalPaddingDiffFromStyle,
hasSafeAreas,
getHeight,
getMinimumHeight,
Expand Down Expand Up @@ -1379,13 +1397,15 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({

/**
* Computes styles for the text input icon container.
* Applies horizontal padding if requested, and sets the top margin based on the presence of a label.
* Applies horizontal padding if requested, and sets the top margin based on padding difference.
*/
getTextInputIconContainerStyles: (hasLabel: boolean, includePadding = true) => {
getTextInputIconContainerStyles: (hasLabel: boolean, includePadding = true, verticalPaddingDiff = 0): ViewStyle => {
const paddingStyle = includePadding ? {paddingHorizontal: 11} : {};
return {
...paddingStyle,
marginTop: hasLabel ? 8 : 16,
marginTop: -(verticalPaddingDiff / 2),
height: '100%',
justifyContent: 'center',
};
},

Expand Down
4 changes: 4 additions & 0 deletions src/styles/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ export default {
lineHeighTaskTitle: getValueUsingPixelRatio(26, 30),
lineHeightSignInHeroXSmall: getValueUsingPixelRatio(32, 37),
inputHeight: getValueUsingPixelRatio(52, 72),
inputPaddingTop: getValueUsingPixelRatio(15, 21),
inputPaddingBottom: getValueUsingPixelRatio(8, 11),
inputHeightSmall: 28,
inputIconMarginTopSmall: getValueUsingPixelRatio(8, 11),
inputIconMarginTopLarge: getValueUsingPixelRatio(16, 21),
formErrorLineHeight: getValueUsingPixelRatio(18, 23),
communicationsLinkHeight: getValueUsingPixelRatio(20, 30),
alternateTextHeight: getValueUsingPixelRatio(20, 24),
Expand Down
Loading