fix: switch checkedChildren no height (#48513)

Co-authored-by: 二货机器人 <smith3816@gmail.com>
This commit is contained in:
Wanpan 2024-04-17 22:25:46 +08:00 committed by GitHub
parent d524a4cd6c
commit 273104cb1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions

View File

@ -68,4 +68,12 @@ describe('Switch', () => {
it('have static property for type detecting', () => {
expect(Switch.__ANT_SWITCH).toBeTruthy();
});
it('inner element have min-height', () => {
const { container, rerender } = render(<Switch unCheckedChildren="0" size="small" />);
expect(container.querySelector('.ant-switch-inner-unchecked')).toHaveStyle('min-height: 16px');
rerender(<Switch unCheckedChildren="0" />);
expect(container.querySelector('.ant-switch-inner-unchecked')).toHaveStyle('min-height: 22px');
});
});

View File

@ -109,6 +109,11 @@ const genSwitchSmallStyle: GenerateStyle<SwitchToken, CSSObject> = (token) => {
[`${componentCls}-inner`]: {
paddingInlineStart: innerMaxMarginSM,
paddingInlineEnd: innerMinMarginSM,
[`${switchInnerCls}-checked, ${switchInnerCls}-unchecked`]: {
minHeight: trackHeightSM,
},
[`${switchInnerCls}-checked`]: {
marginInlineStart: `calc(-100% + ${trackPaddingCalc} - ${innerMaxMarginCalc})`,
marginInlineEnd: `calc(100% - ${trackPaddingCalc} + ${innerMaxMarginCalc})`,
@ -269,6 +274,7 @@ const genSwitchInnerStyle: GenerateStyle<SwitchToken, CSSObject> = (token) => {
fontSize: token.fontSizeSM,
transition: `margin-inline-start ${token.switchDuration} ease-in-out, margin-inline-end ${token.switchDuration} ease-in-out`,
pointerEvents: 'none',
minHeight: trackHeight,
},
[`${switchInnerCls}-checked`]: {