Skip to content

Commit 17c1314

Browse files
committed
fix: prevent counter update on wrong value type
1 parent 753add4 commit 17c1314

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/components/textInput/TextInputBase.tsx

+15-4
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,27 @@ const styles = StyleSheet.create({
120120

121121
type InputTextHelperRow = Pick<
122122
InputTextProps,
123-
"value" | "counterLimit" | "bottomMessage" | "bottomMessageColor"
123+
| "value"
124+
| "counterLimit"
125+
| "bottomMessage"
126+
| "bottomMessageColor"
127+
| "inputType"
124128
>;
125129

126130
const HelperRow = ({
127131
value,
128132
counterLimit,
129133
bottomMessage,
130-
bottomMessageColor
134+
bottomMessageColor,
135+
inputType
131136
}: InputTextHelperRow) => {
132137
const theme = useIOTheme();
133-
const valueCount = useMemo(() => value.length, [value]);
138+
139+
const valueCount = useMemo(
140+
() =>
141+
inputType !== "default" ? value.replace(/\s/g, "").length : value.length,
142+
[inputType, value]
143+
);
134144

135145
const bottomMessageColorDefault: IOColors = theme["textBody-tertiary"];
136146
const bottomMessageColorValue =
@@ -518,10 +528,11 @@ export const TextInputBase = ({
518528

519529
{(bottomMessage || counterLimit) && (
520530
<HelperRow
521-
value={value}
531+
value={inputValue}
522532
bottomMessage={bottomMessage}
523533
bottomMessageColor={bottomMessageColor}
524534
counterLimit={counterLimit}
535+
inputType={inputType}
525536
/>
526537
)}
527538
</>

0 commit comments

Comments
 (0)