From add12a01979a62444fe69ec05138941d286305dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B9=A4=E4=BB=99?= Date: Tue, 15 Oct 2024 13:57:48 +0800 Subject: [PATCH] fix: add root element for SingleSelector to make layout easier --- assets/index.less | 5 + src/Selector/MultipleSelector.tsx | 4 +- src/Selector/SingleSelector.tsx | 4 +- tests/__snapshots__/Combobox.test.tsx.snap | 72 ++- tests/__snapshots__/Multiple.test.tsx.snap | 532 ++++++++--------- tests/__snapshots__/Select.test.tsx.snap | 276 +++++---- tests/__snapshots__/Tags.test.tsx.snap | 644 +++++++++++---------- tests/__snapshots__/ssr.test.tsx.snap | 2 +- 8 files changed, 806 insertions(+), 733 deletions(-) diff --git a/assets/index.less b/assets/index.less index f2eb17b8..e8ba28ba 100644 --- a/assets/index.less +++ b/assets/index.less @@ -70,6 +70,11 @@ display: flex; position: relative; + .@{select-prefix}-selection-wrap { + width: 100%; + position: relative; + } + .@{select-prefix}-selection-search { width: 100%; position: relative; diff --git a/src/Selector/MultipleSelector.tsx b/src/Selector/MultipleSelector.tsx index 5fbe1503..5c7fac70 100644 --- a/src/Selector/MultipleSelector.tsx +++ b/src/Selector/MultipleSelector.tsx @@ -242,12 +242,12 @@ const SelectSelector: React.FC = (props) => { ); return ( - <> + {selectionNode} {!values.length && !inputValue && ( {placeholder} )} - + ); }; diff --git a/src/Selector/SingleSelector.tsx b/src/Selector/SingleSelector.tsx index 4fe56b86..7f71adf8 100644 --- a/src/Selector/SingleSelector.tsx +++ b/src/Selector/SingleSelector.tsx @@ -77,7 +77,7 @@ const SingleSelector: React.FC = (props) => { }, [item, hasTextInput, placeholder, prefixCls]); return ( - <> + = (props) => { {item.label} ) : null} - + ); }; diff --git a/tests/__snapshots__/Combobox.test.tsx.snap b/tests/__snapshots__/Combobox.test.tsx.snap index 806f9ea7..7d8f82d1 100644 --- a/tests/__snapshots__/Combobox.test.tsx.snap +++ b/tests/__snapshots__/Combobox.test.tsx.snap @@ -8,25 +8,29 @@ exports[`Select.Combobox renders controlled correctly 1`] = ` class="rc-select-selector" > - - Search + + + Search + @@ -41,25 +45,29 @@ exports[`Select.Combobox renders correctly 1`] = ` class="rc-select-selector" > - - Search + + + Search + diff --git a/tests/__snapshots__/Multiple.test.tsx.snap b/tests/__snapshots__/Multiple.test.tsx.snap index 8e83d55b..a84f838f 100644 --- a/tests/__snapshots__/Multiple.test.tsx.snap +++ b/tests/__snapshots__/Multiple.test.tsx.snap @@ -7,45 +7,49 @@ exports[`Select.Multiple max tag render not display maxTagPlaceholder if maxTagC
-
-
- + + `; @@ -57,112 +61,116 @@ exports[`Select.Multiple max tag render truncates tags by maxTagCount and show m
-
- - One - - - -
-
- +
- Two - - - -
-
- +
- - Omitted + + + Omitted + - -
-
+
-
+
`; @@ -174,113 +182,117 @@ exports[`Select.Multiple max tag render truncates tags by maxTagCount and show m
-
- - One - - - -
-
- +
- Two - - - -
-
- +
- - 1 - values omitted + + + 1 + values omitted + - -
-
+
-
+
`; @@ -292,96 +304,100 @@ exports[`Select.Multiple max tag render truncates values by maxTagTextLength 1`]
-
- - On... - - - -
-
- +
- Tw... - - - -
-
+
-
+
`; diff --git a/tests/__snapshots__/Select.test.tsx.snap b/tests/__snapshots__/Select.test.tsx.snap index 7054f61c..be851696 100644 --- a/tests/__snapshots__/Select.test.tsx.snap +++ b/tests/__snapshots__/Select.test.tsx.snap @@ -116,30 +116,34 @@ exports[`Select.Basic no search 1`] = ` class="rc-select-selector" > - - - - 1 + + + + + 1 + @@ -155,29 +159,33 @@ exports[`Select.Basic render renders aria-attributes correctly 1`] = ` class="antd-selector" > - - - - 2 + + + + + 2 + - - - - 2 + + + + + 2 + - - - - 2 + + + + + 2 + - - - - 2 + + + + + 2 + @@ -335,27 +355,31 @@ exports[`Select.Basic render renders role prop correctly 1`] = ` class="antd-selector" > - - - - 2 + + + + + 2 + -
- - Jack - - - -
-
- +
- foo - - - -
-
+
- +
-
-
- + + `; @@ -282,109 +290,113 @@ exports[`Select.Tags max tag render truncates tags by maxTagCount and show maxTa
-
- - One - - - -
-
- +
- Two - - - -
-
- +
- - Omitted + + + Omitted + - -
-
+
-
+
`; @@ -396,110 +408,114 @@ exports[`Select.Tags max tag render truncates tags by maxTagCount and show maxTa
-
- - One - - - -
-
- +
- Two - - - -
-
- +
- - 1 - values omitted + + + 1 + values omitted + - -
-
+
-
+
`; @@ -511,93 +527,97 @@ exports[`Select.Tags max tag render truncates values by maxTagTextLength 1`] = `
-
- - On... - - - -
-
- +
- Tw... - - - -
-
+
-
+
`; diff --git a/tests/__snapshots__/ssr.test.tsx.snap b/tests/__snapshots__/ssr.test.tsx.snap index de916d8d..8594094b 100644 --- a/tests/__snapshots__/ssr.test.tsx.snap +++ b/tests/__snapshots__/ssr.test.tsx.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Select.SSR should work 1`] = `"
"`; +exports[`Select.SSR should work 1`] = `"
"`;