Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add root element for SingleSelector to make layout easier #1076

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
display: flex;
position: relative;

.@{select-prefix}-selection-wrap {
width: 100%;
position: relative;
}

.@{select-prefix}-selection-search {
width: 100%;
position: relative;
Expand Down
4 changes: 2 additions & 2 deletions src/Selector/MultipleSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ const SelectSelector: React.FC<SelectorProps> = (props) => {
);

return (
<>
<span className={`${selectionPrefixCls}-wrap`}>
{selectionNode}
{!values.length && !inputValue && (
<span className={`${selectionPrefixCls}-placeholder`}>{placeholder}</span>
)}
</>
</span>
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/Selector/SingleSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const SingleSelector: React.FC<SelectorProps> = (props) => {
}, [item, hasTextInput, placeholder, prefixCls]);

return (
<>
<span className={`${prefixCls}-selection-wrap`}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<span className={`${prefixCls}-selection-wrap`}>
<span className={`${prefixCls}-selection`}>

不需要加 wrap

Copy link
Member

@zombieJ zombieJ Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeholder 特殊标记使用:classNames(xx-selection, xxx-selection-placeholder)

看起来是额外多一层?结构保持一致把,Single 和 Multiple 要加就一起加了:
https://github.com/react-component/select/blob/master/src/Selector/SingleSelector.tsx#L80
https://github.com/react-component/select/blob/master/src/Selector/MultipleSelector.tsx#L245

<span className={`${prefixCls}-selection-search`}>
<Input
ref={inputRef}
Expand Down Expand Up @@ -121,7 +121,7 @@ const SingleSelector: React.FC<SelectorProps> = (props) => {
{item.label}
</span>
) : null}
</>
</span>
);
};

Expand Down
72 changes: 40 additions & 32 deletions tests/__snapshots__/Combobox.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,29 @@ exports[`Select.Combobox renders controlled correctly 1`] = `
class="rc-select-selector"
>
<span
class="rc-select-selection-search"
class="rc-select-selection-wrap"
>
<input
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
aria-haspopup="listbox"
aria-owns="rc_select_TEST_OR_SSR_list"
autocomplete="off"
class="rc-select-selection-search-input"
id="rc_select_TEST_OR_SSR"
role="combobox"
type="search"
value=""
/>
<span
class="rc-select-selection-placeholder"
class="rc-select-selection-search"
>
Search
<input
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
aria-haspopup="listbox"
aria-owns="rc_select_TEST_OR_SSR_list"
autocomplete="off"
class="rc-select-selection-search-input"
id="rc_select_TEST_OR_SSR"
role="combobox"
type="search"
value=""
/>
<span
class="rc-select-selection-placeholder"
>
Search
</span>
</span>
</span>
</div>
Expand All @@ -41,25 +45,29 @@ exports[`Select.Combobox renders correctly 1`] = `
class="rc-select-selector"
>
<span
class="rc-select-selection-search"
class="rc-select-selection-wrap"
>
<input
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
aria-haspopup="listbox"
aria-owns="rc_select_TEST_OR_SSR_list"
autocomplete="off"
class="rc-select-selection-search-input"
id="rc_select_TEST_OR_SSR"
role="combobox"
type="search"
value=""
/>
<span
class="rc-select-selection-placeholder"
class="rc-select-selection-search"
>
Search
<input
aria-autocomplete="list"
aria-controls="rc_select_TEST_OR_SSR_list"
aria-expanded="false"
aria-haspopup="listbox"
aria-owns="rc_select_TEST_OR_SSR_list"
autocomplete="off"
class="rc-select-selection-search-input"
id="rc_select_TEST_OR_SSR"
role="combobox"
type="search"
value=""
/>
<span
class="rc-select-selection-placeholder"
>
Search
</span>
</span>
</span>
</div>
Expand Down
Loading
Loading