Skip to content

Commit

Permalink
fix: 修改disableDate属性在YearPanel的错误视图 (#850)
Browse files Browse the repository at this point in the history
* 修改yearPanel中的disabled显示试图的问题

* Update index.tsx

修改拼写错误

* test: update test case

---------

Co-authored-by: l30053176 <[email protected]>
Co-authored-by: 二货机器人 <[email protected]>
  • Loading branch information
3 people committed Jul 29, 2024
1 parent 9e4b0a7 commit 02d106c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/PickerPanel/YearPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,9 @@ export default function YearPanel<DateType extends object = any>(
const startDate = generateConfig.setDate(startMonth, 1);

// End
const endMonth = generateConfig.setMonth(
currentDate,
generateConfig.getMonth(currentDate) + 1,
);
const enDate = generateConfig.addDate(endMonth, -1);

return disabledDate(startDate, disabledInfo) && disabledDate(enDate, disabledInfo);
const endMonth = generateConfig.addYear(startDate, 1);
const endDate = generateConfig.addDate(endMonth, -1);
return disabledDate(startDate, disabledInfo) && disabledDate(endDate, disabledInfo);
}
: null;

Expand Down
11 changes: 11 additions & 0 deletions tests/panel.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -715,4 +715,15 @@ describe('Picker.Panel', () => {
expect(container.querySelector('.rc-picker-header-view').textContent).toEqual('01:02:03 AM');
});

it('year panel disabled check', () => {
const { container } = render(
<DayPickerPanel
picker="year"
disabledDate={(date) => date.isBefore(getDay('1990-12-25'))}
defaultValue={getDay('1990-01-01')}
/>,
);

expect(container.querySelector('.rc-picker-cell-selected').textContent).toEqual('1990');
});
});

0 comments on commit 02d106c

Please sign in to comment.