From 5d12b57a84fb8771a708e226f2a7bf47bdf3f1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?w=C5=AB=20y=C4=81ng?= Date: Wed, 15 Nov 2023 11:13:56 +0800 Subject: [PATCH] fix(Input): fix input max length (#2598) * fix(input): fix input maxlength behavior * chore: update common * chore: update snapshot --- src/_common | 2 +- src/input/Input.tsx | 1 + src/input/_example/max-length-count.jsx | 4 ++-- test/snap/__snapshots__/csr.test.jsx.snap | 12 ++++++++---- test/snap/__snapshots__/ssr.test.jsx.snap | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/_common b/src/_common index b62cac6f5d..16229778d5 160000 --- a/src/_common +++ b/src/_common @@ -1 +1 @@ -Subproject commit b62cac6f5d75b1af5b527a2849bedee42e906d6d +Subproject commit 16229778d5c97e66d81b4107171a2af00a7b262d diff --git a/src/input/Input.tsx b/src/input/Input.tsx index 18df1b071d..a996a1cf79 100644 --- a/src/input/Input.tsx +++ b/src/input/Input.tsx @@ -226,6 +226,7 @@ const Input = forwardRefWithStatics( onBlur={handleBlur} onPaste={handlePaste} name={name} + maxLength={maxlength && !allowInputOverMax ? maxlength : null} /> ); diff --git a/src/input/_example/max-length-count.jsx b/src/input/_example/max-length-count.jsx index 6fa5069699..a55b09200f 100644 --- a/src/input/_example/max-length-count.jsx +++ b/src/input/_example/max-length-count.jsx @@ -14,9 +14,9 @@ export default function InputExample() { csr test src/input/_example/max-length-count.jsx 1` > @@ -116583,7 +116584,7 @@ exports[`csr snapshot test > csr test src/input/_example/max-length-count.jsx 1`
- 0/5 + 0/10
@@ -116657,6 +116658,7 @@ exports[`csr snapshot test > csr test src/input/_example/max-length-count.jsx 1` > csr test src/input/_example/max-length-count.jsx 1` > @@ -116699,7 +116702,7 @@ exports[`csr snapshot test > csr test src/input/_example/max-length-count.jsx 1`
- 0/5 + 0/10
@@ -116773,6 +116776,7 @@ exports[`csr snapshot test > csr test src/input/_example/max-length-count.jsx 1` > ssr test src/input/_example/format.jsx 1`] = `"
ssr test src/input/_example/group.jsx 1`] = `"
 - 
"`; -exports[`ssr snapshot test > ssr test src/input/_example/max-length-count.jsx 1`] = `"
0/5
0/10
0/5
0/5
"`; +exports[`ssr snapshot test > ssr test src/input/_example/max-length-count.jsx 1`] = `"
0/10
0/10
0/5
0/5
"`; exports[`ssr snapshot test > ssr test src/input/_example/password.jsx 1`] = `"
"`;