Skip to content

Commit a88f2d9

Browse files
authored
Add the hideErrorMessage prop to text input (#510)
* Add the 'hideErrorMessage' prop to text input * Remove default value * v4.3.7
1 parent baed8a6 commit a88f2d9

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netdata/netdata-ui",
3-
"version": "4.3.6",
3+
"version": "4.3.7",
44
"description": "netdata UI kit",
55
"main": "dist/index.js",
66
"module": "dist/es6/index.js",

src/components/input/input.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import Flex from "@/components/templates/flex"
33
import { TextMicro } from "@/components/typography"
44
import { Input, LabelText } from "./styled"
55

6+
const Error = ({ error }) => {
7+
const errorMessage = error === true ? "invalid" : error
8+
9+
return typeof errorMessage === "string" ? (
10+
<TextMicro color="errorText">{errorMessage}</TextMicro>
11+
) : (
12+
!!errorMessage && errorMessage
13+
)
14+
}
15+
616
export const TextInput = ({
717
error,
818
disabled,
@@ -21,10 +31,9 @@ export const TextInput = ({
2131
size = "large",
2232
containerStyles,
2333
inputContainerStyles,
34+
hideErrorMessage,
2435
...props
2536
}) => {
26-
const errorMessage = error === true ? "invalid" : error
27-
2837
return (
2938
<Flex gap={0.5} column className={className} {...containerStyles} as="label">
3039
{typeof label === "string" ? <LabelText size={size}>{label}</LabelText> : label}
@@ -61,11 +70,7 @@ export const TextInput = ({
6170
)}
6271
</Flex>
6372
{typeof hint === "string" ? <TextMicro color="textLite">{hint}</TextMicro> : !!hint && hint}
64-
{typeof errorMessage === "string" ? (
65-
<TextMicro color="errorText">{errorMessage}</TextMicro>
66-
) : (
67-
!!errorMessage && errorMessage
68-
)}
73+
{!hideErrorMessage ? <Error error={error} /> : null}
6974
</Flex>
7075
)
7176
}

0 commit comments

Comments
 (0)