Skip to content
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
10 changes: 9 additions & 1 deletion src/components/MagicCodeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CONST from '../CONST';
import Text from './Text';
import TextInput from './TextInput';
import FormHelpMessage from './FormHelpMessage';
import * as Browser from '../libs/Browser';

const propTypes = {
/** Name attribute for the input */
Expand Down Expand Up @@ -255,6 +256,11 @@ function MagicCodeInput(props) {
}
};

// We need to check the browser because, in iOS Safari, an input in a container with its opacity set to
// 0 (completely transparent) cannot handle user interaction, hence the Paste option is never shown.
// Alternate styling will be applied based on this condition.
const isMobileSafari = Browser.isMobileSafari();

return (
<>
<View style={[styles.magicCodeInputContainer]}>
Expand All @@ -266,7 +272,7 @@ function MagicCodeInput(props) {
<View style={[styles.textInputContainer, focusedIndex === index ? styles.borderColorFocus : {}]}>
<Text style={[styles.magicCodeInput, styles.textAlignCenter]}>{decomposeString(props.value)[index] || ''}</Text>
</View>
<View style={[StyleSheet.absoluteFillObject, styles.w100, styles.opacity0]}>
<View style={[StyleSheet.absoluteFillObject, styles.w100, isMobileSafari ? styles.bgTransparent : styles.opacity0]}>
<TextInput
ref={(ref) => (inputRefs.current[index] = ref)}
autoFocus={index === 0 && props.autoFocus}
Expand All @@ -291,6 +297,8 @@ function MagicCodeInput(props) {
onKeyPress={onKeyPress}
onPress={(event) => onPress(event, index)}
onFocus={onFocus}
caretHidden={isMobileSafari}
inputStyle={[isMobileSafari ? styles.magicCodeInputTransparent : undefined]}
/>
</View>
</View>
Expand Down
4 changes: 4 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,10 @@ const styles = {
lineHeight: variables.inputHeight,
},

magicCodeInputTransparent: {
color: 'transparent',
},

iouAmountText: {
...headlineFont,
fontSize: variables.iouAmountTextSize,
Expand Down