Skip to content

TextField - fix validationIcon with no validationMassage #3114

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

Merged
merged 2 commits into from
Jun 2, 2024
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
2 changes: 1 addition & 1 deletion demo/src/screens/componentScreens/TextFieldScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export default class TextFieldScreen extends Component {
containerStyle={{flex: 1}}
validationMessagePosition={errorPosition}
helperText={'Enter first and last name'}
validationIcon={validationIcon}
validationIcon={{source: validationIcon, style: {marginTop: 1}}}
/>
<Button
outline
Expand Down
5 changes: 3 additions & 2 deletions src/components/textField/ValidationMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ const ValidationMessage = ({
);
};

if (validationIcon) {
if (validationIcon?.source) {
return (
<View row>
<Icon source={validationIcon} tintColor={Colors.$textDangerLight} size={14} marginR-s1 marginT-1/>
{showValidationMessage &&
<Icon tintColor={Colors.$textDangerLight} size={14} marginR-s1 {...validationIcon}/>}
{renderMessage()}
</View>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/textField/textField.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"type": "string | string[]",
"description": "The validation message to display when field is invalid (depends on validate)"
},
{"name": "validationIcon", "type": "ImageProps['source']", "description": "Icon left to the validation message"},
{"name": "validationIcon", "type": "IconProps", "description": "Icon left to the validation message"},
{
"name": "validationMessagePosition",
"type": "ValidationMessagePosition",
Expand Down
4 changes: 2 additions & 2 deletions src/components/textField/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {TextProps} from '../text';
import {RecorderProps} from '../../typings/recorderTypes';
import {PropsWithChildren, ReactElement} from 'react';
import {ViewProps} from '../view';
import type {ImageProps} from '../image';
import type {IconProps} from '../icon';

export type ColorType =
| string
Expand Down Expand Up @@ -129,7 +129,7 @@ export interface ValidationMessageProps {
/**
* Icon left to the validation message
*/
validationIcon?: ImageProps['source'];
validationIcon?: IconProps;
/**
* Keep the validation space even if there is no validation message
*/
Expand Down