mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 22:36:31 +08:00
style: fix calendar style inside Form.Item (#30442)
* style: fix calendar style inside Form.Item * fix: Calendar set null/undefined throws error close #30392
This commit is contained in:
parent
0b0849b107
commit
8a599a099f
@ -31,7 +31,7 @@ function YearSelect<DateType>(props: SharedProps<DateType>) {
|
||||
divRef,
|
||||
} = props;
|
||||
|
||||
const year = generateConfig.getYear(value);
|
||||
const year = generateConfig.getYear(value || generateConfig.getNow());
|
||||
|
||||
let start = year - YearSelectOffset;
|
||||
let end = start + YearSelectTotal;
|
||||
@ -92,7 +92,7 @@ function MonthSelect<DateType>(props: SharedProps<DateType>) {
|
||||
onChange,
|
||||
divRef,
|
||||
} = props;
|
||||
const month = generateConfig.getMonth(value);
|
||||
const month = generateConfig.getMonth(value || generateConfig.getNow());
|
||||
|
||||
let start = 0;
|
||||
let end = 11;
|
||||
|
@ -27,6 +27,18 @@ describe('Calendar', () => {
|
||||
findSelectItem(wrapper).at(index).simulate('click');
|
||||
}
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/30392
|
||||
it('should be able to set undefined or null', () => {
|
||||
expect(() => {
|
||||
const wrapper = mount(<Calendar />);
|
||||
wrapper.setProps({ value: null });
|
||||
}).not.toThrow();
|
||||
expect(() => {
|
||||
const wrapper = mount(<Calendar />);
|
||||
wrapper.setProps({ value: undefined });
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('Calendar should be selectable', () => {
|
||||
const onSelect = jest.fn();
|
||||
const onChange = jest.fn();
|
||||
|
@ -61,7 +61,9 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
// Don't impact select inside input group
|
||||
// Don't impact select inside input group and calendar header select
|
||||
.@{ant-prefix}-picker-calendar-year-select,
|
||||
.@{ant-prefix}-picker-calendar-month-select,
|
||||
.@{ant-prefix}-input-group .@{ant-prefix}-select,
|
||||
.@{ant-prefix}-input-group .@{ant-prefix}-cascader-picker {
|
||||
width: auto;
|
||||
|
Loading…
Reference in New Issue
Block a user