mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
fix: select small height (#44859)
This commit is contained in:
parent
afcdc3fbe2
commit
102c4654e1
@ -16,6 +16,7 @@ const handleChange = (value: string[]) => {
|
||||
};
|
||||
|
||||
const App: React.FC = () => (
|
||||
<Space direction="vertical">
|
||||
<ConfigProvider
|
||||
theme={{
|
||||
components: {
|
||||
@ -48,6 +49,36 @@ const App: React.FC = () => (
|
||||
/>
|
||||
</Space>
|
||||
</ConfigProvider>
|
||||
<ConfigProvider
|
||||
theme={{
|
||||
token: {
|
||||
controlHeightSM: 28,
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Space style={{ width: '100%' }} direction="vertical">
|
||||
<Select
|
||||
mode="multiple"
|
||||
allowClear
|
||||
size="small"
|
||||
style={{ width: '100%' }}
|
||||
placeholder="Please select"
|
||||
defaultValue={['a10', 'c12']}
|
||||
onChange={handleChange}
|
||||
options={options}
|
||||
/>
|
||||
<Select
|
||||
mode="multiple"
|
||||
allowClear
|
||||
style={{ width: '100%' }}
|
||||
placeholder="Please select"
|
||||
defaultValue={['a10', 'c12']}
|
||||
onChange={handleChange}
|
||||
options={options}
|
||||
/>
|
||||
</Space>
|
||||
</ConfigProvider>
|
||||
</Space>
|
||||
);
|
||||
|
||||
export default App;
|
||||
|
@ -110,6 +110,7 @@ export interface SelectToken extends FullToken<'Select'> {
|
||||
rootPrefixCls: string;
|
||||
inputPaddingHorizontalBase: number;
|
||||
multipleSelectItemHeight: number;
|
||||
selectHeight: number;
|
||||
}
|
||||
|
||||
// ============================= Selector =============================
|
||||
@ -434,6 +435,7 @@ export default genComponentStyleHook(
|
||||
rootPrefixCls,
|
||||
inputPaddingHorizontalBase: token.paddingSM - 1,
|
||||
multipleSelectItemHeight: token.multipleItemHeight,
|
||||
selectHeight: token.controlHeight,
|
||||
});
|
||||
|
||||
return [genSelectStyle(selectToken)];
|
||||
|
@ -6,11 +6,11 @@ import { mergeToken } from '../../theme/internal';
|
||||
const FIXED_ITEM_MARGIN = 2;
|
||||
|
||||
const getSelectItemStyle = ({
|
||||
controlHeightSM,
|
||||
controlHeight,
|
||||
multipleSelectItemHeight,
|
||||
selectHeight,
|
||||
lineWidth: borderWidth,
|
||||
}: SelectToken): readonly [number, number] => {
|
||||
const selectItemDist = (controlHeight - controlHeightSM) / 2 - borderWidth;
|
||||
const selectItemDist = (selectHeight - multipleSelectItemHeight) / 2 - borderWidth;
|
||||
const selectItemMargin = Math.ceil(selectItemDist / 2);
|
||||
return [selectItemDist, selectItemMargin] as const;
|
||||
};
|
||||
@ -202,7 +202,7 @@ const genMultipleStyle = (token: SelectToken): CSSInterpolation => {
|
||||
const { componentCls } = token;
|
||||
|
||||
const smallToken = mergeToken<SelectToken>(token, {
|
||||
controlHeight: token.controlHeightSM,
|
||||
selectHeight: token.controlHeightSM,
|
||||
multipleSelectItemHeight: token.controlHeightXS,
|
||||
borderRadius: token.borderRadiusSM,
|
||||
borderRadiusSM: token.borderRadiusXS,
|
||||
@ -210,7 +210,7 @@ const genMultipleStyle = (token: SelectToken): CSSInterpolation => {
|
||||
|
||||
const largeToken = mergeToken<SelectToken>(token, {
|
||||
fontSize: token.fontSizeLG,
|
||||
controlHeight: token.controlHeightLG,
|
||||
selectHeight: token.controlHeightLG,
|
||||
multipleSelectItemHeight: token.multipleItemHeightLG,
|
||||
borderRadius: token.borderRadiusLG,
|
||||
borderRadiusSM: token.borderRadius,
|
||||
|
Loading…
Reference in New Issue
Block a user