diff --git a/src/components/AmountTextInput.tsx b/src/components/AmountTextInput.tsx index 3db23eb636b9..76218b35c043 100644 --- a/src/components/AmountTextInput.tsx +++ b/src/components/AmountTextInput.tsx @@ -41,7 +41,7 @@ type AmountTextInputProps = { /** Hide the focus styles on TextInput */ hideFocusedState?: boolean; -} & Pick; +} & Pick; function AmountTextInput({ formattedAmount, @@ -57,6 +57,7 @@ function AmountTextInput({ hideFocusedState = true, shouldApplyPaddingToContainer = false, ref, + disabled, ...rest }: AmountTextInputProps) { return ( @@ -69,6 +70,7 @@ function AmountTextInput({ textInputContainerStyles={containerStyle} onChangeText={onChangeAmount} ref={ref} + disabled={disabled} value={formattedAmount} placeholder={placeholder} inputMode={CONST.INPUT_MODE.DECIMAL} diff --git a/src/components/MoneyRequestAmountInput.tsx b/src/components/MoneyRequestAmountInput.tsx index 261f4863cce4..980ea00e2c02 100644 --- a/src/components/MoneyRequestAmountInput.tsx +++ b/src/components/MoneyRequestAmountInput.tsx @@ -116,6 +116,9 @@ type MoneyRequestAmountInputProps = { */ shouldWrapInputInContainer?: boolean; + /** Whether the input is disabled or not */ + disabled?: boolean; + /** Reference to the outer element */ ref?: ForwardedRef; } & Pick; @@ -160,6 +163,7 @@ function MoneyRequestAmountInput({ toggleNegative, clearNegative, ref, + disabled, ...props }: MoneyRequestAmountInputProps) { const textInput = useRef(null); @@ -214,6 +218,7 @@ function MoneyRequestAmountInput({ // eslint-disable-next-line react-compiler/react-compiler textInput.current = newRef; }} + disabled={disabled} numberFormRef={(newRef) => { if (typeof moneyRequestAmountInputRef === 'function') { moneyRequestAmountInputRef(newRef); diff --git a/src/components/NumberWithSymbolForm.tsx b/src/components/NumberWithSymbolForm.tsx index 2710cbfe0b74..4353a8e25f23 100644 --- a/src/components/NumberWithSymbolForm.tsx +++ b/src/components/NumberWithSymbolForm.tsx @@ -79,6 +79,9 @@ type NumberWithSymbolFormProps = { /** Whether to allow flipping amount */ allowFlippingAmount?: boolean; + /** Whether the input is disabled or not */ + disabled?: boolean; + /** Reference to the outer element */ ref?: ForwardedRef; } & Omit; @@ -141,6 +144,7 @@ function NumberWithSymbolForm({ toggleNegative, clearNegative, ref, + disabled, ...props }: NumberWithSymbolFormProps) { const styles = useThemeStyles(); @@ -369,6 +373,7 @@ function NumberWithSymbolForm({ ref.current = newRef; } }} + disabled={disabled} prefixCharacter={symbol} prefixStyle={styles.colorMuted} keyboardType={CONST.KEYBOARD_TYPE.DECIMAL_PAD} @@ -400,6 +405,7 @@ function NumberWithSymbolForm({ } textInput.current = newRef; }} + disabled={disabled} symbol={symbol} hideSymbol={hideSymbol} symbolPosition={symbolPosition} diff --git a/src/components/SelectionListWithSections/SplitListItem.tsx b/src/components/SelectionListWithSections/SplitListItem.tsx index f5b7c09d23ca..a138ca5ddd71 100644 --- a/src/components/SelectionListWithSections/SplitListItem.tsx +++ b/src/components/SelectionListWithSections/SplitListItem.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useLayoutEffect, useRef, useState} from 'react'; +import React, {useCallback, useLayoutEffect, useRef} from 'react'; import {View} from 'react-native'; import Icon from '@components/Icon'; // eslint-disable-next-line no-restricted-imports @@ -59,8 +59,6 @@ function SplitListItem({ const isBottomVisible = !!splitItem.category || !!splitItem.tags?.at(0); - const [prefixCharacterMargin, setPrefixCharacterMargin] = useState(CONST.CHARACTER_WIDTH); - const inputMarginLeft = prefixCharacterMargin + styles.pl1.paddingLeft; const contentWidth = (formattedOriginalAmount.length + 1) * CONST.CHARACTER_WIDTH; const focusHandler = useCallback(() => { if (!onInputFocus) { @@ -166,54 +164,33 @@ function SplitListItem({ - {!splitItem.isEditable ? ( - - { - if (event.nativeEvent.layout.width === 0 && event.nativeEvent.layout.height === 0) { - return; - } - setPrefixCharacterMargin(event?.nativeEvent?.layout.width); - }} - > - {splitItem.currencySymbol} - - - {convertToDisplayStringWithoutCurrency(splitItem.amount, splitItem.currency)} - - - ) : ( - - )} + {!splitItem.isEditable ? null : ( diff --git a/src/components/TextInput/BaseTextInput/implementation/index.tsx b/src/components/TextInput/BaseTextInput/implementation/index.tsx index b8694d165505..3560897c3caf 100644 --- a/src/components/TextInput/BaseTextInput/implementation/index.tsx +++ b/src/components/TextInput/BaseTextInput/implementation/index.tsx @@ -373,7 +373,13 @@ function BaseTextInput({ setIsPrefixCharacterPaddingCalculated(true); }} tabIndex={-1} - style={[styles.textInputPrefix, !hasLabel && styles.pv0, styles.pointerEventsNone, prefixStyle]} + style={[ + styles.textInputPrefix, + !hasLabel && styles.pv0, + styles.pointerEventsNone, + inputProps.disabled && shouldUseDisabledStyles && styles.textSupporting, + prefixStyle, + ]} dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}} shouldUseDefaultLineHeight={shouldUseDefaultLineHeightForPrefix} > diff --git a/src/components/TextInputWithSymbol/BaseTextInputWithSymbol.tsx b/src/components/TextInputWithSymbol/BaseTextInputWithSymbol.tsx index 24cd212be6b6..9f9d1d6d061f 100644 --- a/src/components/TextInputWithSymbol/BaseTextInputWithSymbol.tsx +++ b/src/components/TextInputWithSymbol/BaseTextInputWithSymbol.tsx @@ -25,6 +25,7 @@ function BaseTextInputWithSymbol({ symbolTextStyle, isNegative = false, ref, + disabled, ...rest }: BaseTextInputWithSymbolProps) { const {fromLocaleDigit} = useLocalize(); @@ -58,6 +59,7 @@ function BaseTextInputWithSymbol({ onChangeAmount={setFormattedAmount} placeholder={placeholder} ref={ref} + disabled={disabled} selection={selection} onSelectionChange={(event: TextInputSelectionChangeEvent) => { onSelectionChange(event); diff --git a/src/components/TextInputWithSymbol/types.ts b/src/components/TextInputWithSymbol/types.ts index e858094c179f..9fa0bda44e4c 100644 --- a/src/components/TextInputWithSymbol/types.ts +++ b/src/components/TextInputWithSymbol/types.ts @@ -101,6 +101,7 @@ type BaseTextInputWithSymbolProps = { | 'shouldUseDefaultLineHeightForPrefix' | 'onFocus' | 'onBlur' + | 'disabled' | 'ref' >;