Skip to content

Commit 5e676fd

Browse files
authored
fix(text-input): add class for inline validation (#12231)
* fix(text-input): add class for inline validation * chore(text-input): rename invalid classname * chore(text-input): update classname for inline invalid * Update TextInput.stories.js
1 parent d30eb9c commit 5e676fd

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

packages/react/src/components/TextInput/TextInput.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ const TextInput = React.forwardRef(function TextInput(
114114
[`${prefix}--text-input-wrapper--readonly`]: readOnly,
115115
[`${prefix}--text-input-wrapper--light`]: light,
116116
[`${prefix}--text-input-wrapper--inline`]: inline,
117+
[`${prefix}--text-input-wrapper--inline--invalid`]:
118+
inline && normalizedProps.invalid,
117119
}
118120
);
119121
const labelClasses = classNames(`${prefix}--label`, {
@@ -195,7 +197,7 @@ const TextInput = React.forwardRef(function TextInput(
195197
) : (
196198
<div className={`${prefix}--text-input__label-helper-wrapper`}>
197199
{labelWrapper}
198-
{!isFluid && helper}
200+
{!isFluid && (normalizedProps.validation || helper)}
199201
</div>
200202
)}
201203
<div className={fieldOuterWrapperClasses}>

packages/react/src/components/TextInput/TextInput.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Playground.argTypes = {
132132
control: {
133133
type: 'text',
134134
},
135-
defaultValue: 'Invalid text',
135+
defaultValue: 'Error message goes here',
136136
},
137137
disabled: {
138138
control: {

packages/styles/scss/components/text-input/_text-input.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,17 @@
392392
flex-direction: column;
393393
}
394394

395+
.#{$prefix}--text-input-wrapper--inline .cds--form-requirement {
396+
display: block;
397+
overflow: visible;
398+
max-height: rem(200px);
399+
font-weight: 400;
400+
}
401+
402+
.#{$prefix}--text-input-wrapper--inline--invalid .cds--form-requirement {
403+
color: $text-error;
404+
}
405+
395406
//-----------------------------
396407
// Readonly
397408
//-----------------------------

0 commit comments

Comments
 (0)