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: Select mutilple config token don't work #48051

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions components/select/__tests__/index.test.tsx
Expand Up @@ -8,6 +8,7 @@ import focusTest from '../../../tests/shared/focusTest';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
import { act, fireEvent, render } from '../../../tests/utils';
import { ConfigProvider } from 'antd';

const { Option } = Select;

Expand Down Expand Up @@ -196,5 +197,21 @@ describe('Select', () => {
);
errSpy.mockRestore();
});

it('should set the height of the multiple select element correctly', () => {
const { container } = render(
<ConfigProvider
theme={{
token: {
controlHeight: 28,
},
}}
>
<Select mode="multiple" style={{ width: 300 }} />
</ConfigProvider>,
);
const select = container.querySelector('.ant-select') as HTMLElement;
expect(select).toHaveStyle('height: 28px');
});
});
});
13 changes: 12 additions & 1 deletion components/select/style/multiple.ts
Expand Up @@ -86,6 +86,11 @@ export const genOverflowStyle = (
| 'multipleItemBorderColorDisabled'
| 'colorIcon'
| 'colorIconHover'
| 'max'
| 'calc'
| 'multipleSelectItemHeight'
| 'paddingXXS'
| 'lineWidth'
>,
): CSSObject => {
const {
Expand All @@ -102,6 +107,8 @@ export const genOverflowStyle = (

const selectOverflowPrefixCls = `${componentCls}-selection-overflow`;

const multipleSelectorUnit = getMultipleSelectorUnit(token);

return {
/**
* Do not merge `height` & `line-height` under style with `selection` & `search`, since chrome
Expand All @@ -110,15 +117,16 @@ export const genOverflowStyle = (
// =========================== Overflow ===========================
[selectOverflowPrefixCls]: {
position: 'relative',
maxWidth: '100%',
display: 'flex',
flex: 'auto',
flexWrap: 'wrap',
maxWidth: '100%',

'&-item': {
flex: 'none',
alignSelf: 'center',
maxWidth: '100%',
height: '100%',
display: 'inline-flex',
},

Expand All @@ -129,6 +137,8 @@ export const genOverflowStyle = (
flex: 'none',
boxSizing: 'border-box',
maxWidth: '100%',
height: multipleSelectorUnit.itemHeight,
lineHeight: unit(multipleSelectorUnit.itemLineHeight),
marginBlock: FIXED_ITEM_MARGIN,
borderRadius: borderRadiusSM,
cursor: 'default',
Expand Down Expand Up @@ -293,6 +303,7 @@ function genSizeStyle(token: SelectToken, suffix?: string): CSSInterpolation {
const rawStyle: CSSObject = {
[`${componentCls}-multiple${suffixCls}`]: {
fontSize: token.fontSize,
height: token.controlHeight,

// ========================= Selector =========================
[`${componentCls}-selector`]: {
Expand Down