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

fix: add red border to the magic code input #18885

Merged
merged 1 commit into from
May 15, 2023
Merged
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 @@ -38,6 +38,9 @@ const propTypes = {

/** Function to call when the input is submitted or fully complete */
onFulfill: PropTypes.func,

/** Specifies if the input has a validation error */
hasError: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -50,6 +53,7 @@ const defaultProps = {
innerRef: null,
onChangeText: () => {},
onFulfill: () => {},
hasError: false,
};

/**
Expand Down Expand Up @@ -263,7 +267,11 @@ function MagicCodeInput(props) {
key={index}
style={[styles.w15]}
>
<View style={[styles.textInputContainer, focusedIndex === index ? styles.borderColorFocus : {}]}>
<View style={[
styles.textInputContainer,
focusedIndex === index ? styles.borderColorFocus : {},
props.hasError || props.errorText ? styles.borderColorDanger : {},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we added the error styling at the last, it overrides the focus style. This caused a regression here

]}>
<Text style={[styles.magicCodeInput, styles.textAlignCenter]}>{decomposeString(props.value)[index] || ''}</Text>
</View>
<View style={[StyleSheet.absoluteFillObject, styles.w100, styles.opacity0]}>
Expand Down