Skip to content

Commit 751feb3

Browse files
committed
TextField - fix validationIcon with no validationMassage (#3114)
* TextField - fix validationIcon with no validationMassage * fix validationIcon type
1 parent a82149b commit 751feb3

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

demo/src/screens/componentScreens/TextFieldScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export default class TextFieldScreen extends Component {
204204
containerStyle={{flex: 1}}
205205
validationMessagePosition={errorPosition}
206206
helperText={'Enter first and last name'}
207-
validationIcon={validationIcon}
207+
validationIcon={{source: validationIcon, style: {marginTop: 1}}}
208208
/>
209209
<Button
210210
outline

src/components/textField/ValidationMessage.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ const ValidationMessage = ({
3636
);
3737
};
3838

39-
if (validationIcon) {
39+
if (validationIcon?.source) {
4040
return (
4141
<View row>
42-
<Icon source={validationIcon} tintColor={Colors.$textDangerLight} size={14} marginR-s1 marginT-1/>
42+
{showValidationMessage &&
43+
<Icon tintColor={Colors.$textDangerLight} size={14} marginR-s1 {...validationIcon}/>}
4344
{renderMessage()}
4445
</View>
4546
);

src/components/textField/textField.api.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"type": "string | string[]",
4949
"description": "The validation message to display when field is invalid (depends on validate)"
5050
},
51-
{"name": "validationIcon", "type": "ImageProps['source']", "description": "Icon left to the validation message"},
51+
{"name": "validationIcon", "type": "IconProps", "description": "Icon left to the validation message"},
5252
{
5353
"name": "validationMessagePosition",
5454
"type": "ValidationMessagePosition",

src/components/textField/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {TextProps} from '../text';
1212
import {RecorderProps} from '../../typings/recorderTypes';
1313
import {PropsWithChildren, ReactElement} from 'react';
1414
import {ViewProps} from '../view';
15-
import type {ImageProps} from '../image';
15+
import type {IconProps} from '../icon';
1616

1717
export type ColorType =
1818
| string
@@ -129,7 +129,7 @@ export interface ValidationMessageProps {
129129
/**
130130
* Icon left to the validation message
131131
*/
132-
validationIcon?: ImageProps['source'];
132+
validationIcon?: IconProps;
133133
/**
134134
* Keep the validation space even if there is no validation message
135135
*/

0 commit comments

Comments
 (0)