Skip to content

Commit

Permalink
fix(text-input): add class for inline validation (#12231)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
aledavila committed Oct 21, 2022
1 parent d30eb9c commit 5e676fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/react/src/components/TextInput/TextInput.js
Expand Up @@ -114,6 +114,8 @@ const TextInput = React.forwardRef(function TextInput(
[`${prefix}--text-input-wrapper--readonly`]: readOnly,
[`${prefix}--text-input-wrapper--light`]: light,
[`${prefix}--text-input-wrapper--inline`]: inline,
[`${prefix}--text-input-wrapper--inline--invalid`]:
inline && normalizedProps.invalid,
}
);
const labelClasses = classNames(`${prefix}--label`, {
Expand Down Expand Up @@ -195,7 +197,7 @@ const TextInput = React.forwardRef(function TextInput(
) : (
<div className={`${prefix}--text-input__label-helper-wrapper`}>
{labelWrapper}
{!isFluid && helper}
{!isFluid && (normalizedProps.validation || helper)}
</div>
)}
<div className={fieldOuterWrapperClasses}>
Expand Down
Expand Up @@ -132,7 +132,7 @@ Playground.argTypes = {
control: {
type: 'text',
},
defaultValue: 'Invalid text',
defaultValue: 'Error message goes here',
},
disabled: {
control: {
Expand Down
11 changes: 11 additions & 0 deletions packages/styles/scss/components/text-input/_text-input.scss
Expand Up @@ -392,6 +392,17 @@
flex-direction: column;
}

.#{$prefix}--text-input-wrapper--inline .cds--form-requirement {
display: block;
overflow: visible;
max-height: rem(200px);
font-weight: 400;
}

.#{$prefix}--text-input-wrapper--inline--invalid .cds--form-requirement {
color: $text-error;
}

//-----------------------------
// Readonly
//-----------------------------
Expand Down

0 comments on commit 5e676fd

Please sign in to comment.