Skip to content

Commit

Permalink
Merge pull request #34332 from software-mansion-labs/hide-fix-erros-a…
Browse files Browse the repository at this point in the history
…lert-in-idology-questions

Wallet - Fix the errors button is non-functional in Additional details
  • Loading branch information
blimpich authored Jan 17, 2024
2 parents 6089720 + e99fbed commit 0ec8556
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/components/Form/FormProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ const propTypes = {

/** Should validate function be called when the value of the input is changed */
shouldValidateOnChange: PropTypes.bool,

/** Should fix the errors alert be displayed when there is an error in the form */
shouldHideFixErrorsAlert: PropTypes.bool,
};

// In order to prevent Checkbox focus loss when the user are focusing a TextInput and proceeds to toggle a CheckBox in web and mobile web.
Expand All @@ -94,6 +97,7 @@ const defaultProps = {
validate: () => {},
shouldValidateOnBlur: true,
shouldValidateOnChange: true,
shouldHideFixErrorsAlert: false,
};

function getInitialValueByType(valueType) {
Expand Down
8 changes: 7 additions & 1 deletion src/components/Form/FormWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const propTypes = {
errors: errorsPropType.isRequired,

inputRefs: PropTypes.objectOf(refPropTypes).isRequired,

shouldHideFixErrorsAlert: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -79,6 +81,7 @@ const defaultProps = {
footerContent: null,
style: [],
submitButtonStyles: [],
shouldHideFixErrorsAlert: false,
};

function FormWrapper(props) {
Expand All @@ -97,6 +100,7 @@ function FormWrapper(props) {
enabledWhenOffline,
isSubmitActionDangerous,
formID,
shouldHideFixErrorsAlert,
} = props;
const formRef = useRef(null);
const formContentRef = useRef(null);
Expand All @@ -117,7 +121,7 @@ function FormWrapper(props) {
{isSubmitButtonVisible && (
<FormAlertWithSubmitButton
buttonText={submitButtonText}
isAlertVisible={_.size(errors) > 0 || Boolean(errorMessage) || !_.isEmpty(formState.errorFields)}
isAlertVisible={((_.size(errors) > 0 || !_.isEmpty(formState.errorFields)) && !shouldHideFixErrorsAlert) || Boolean(errorMessage)}
isLoading={formState.isLoading}
message={_.isEmpty(formState.errorFields) ? errorMessage : null}
onSubmit={onSubmit}
Expand Down Expand Up @@ -153,6 +157,7 @@ function FormWrapper(props) {
enabledWhenOffline={enabledWhenOffline}
isSubmitActionDangerous={isSubmitActionDangerous}
disablePressOnEnter
shouldHideFixErrorsAlert={shouldHideFixErrorsAlert}
/>
)}
</FormSubmit>
Expand All @@ -176,6 +181,7 @@ function FormWrapper(props) {
styles.mt5,
submitButtonStyles,
submitButtonText,
shouldHideFixErrorsAlert,
],
);

Expand Down
5 changes: 3 additions & 2 deletions src/components/RadioButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useState} from 'react';
import {View} from 'react-native';
import useThemeStyles from '@hooks/useThemeStyles';
import RadioButtonWithLabel from './RadioButtonWithLabel';

Expand All @@ -20,7 +21,7 @@ function RadioButtons({items, onPress}: RadioButtonsProps) {
const [checkedValue, setCheckedValue] = useState('');

return (
<>
<View style={styles.mb3}>
{items.map((item) => (
<RadioButtonWithLabel
key={item.value}
Expand All @@ -33,7 +34,7 @@ function RadioButtons({items, onPress}: RadioButtonsProps) {
label={item.label}
/>
))}
</>
</View>
);
}

Expand Down
1 change: 1 addition & 0 deletions src/pages/EnablePayments/IdologyQuestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ function IdologyQuestions({questions, idNumber}) {
scrollContextEnabled
style={[styles.flexGrow1, styles.ph5]}
submitButtonText={translate('common.saveAndContinue')}
shouldHideFixErrorsAlert
>
<InputWrapper
InputComponent={SingleChoiceQuestion}
Expand Down

0 comments on commit 0ec8556

Please sign in to comment.