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: 修改disableDate属性在YearPanel的错误视图 #850

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
Loading