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: Year Panel super prev disabled logic #893

Merged
merged 2 commits into from
Nov 13, 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
8 changes: 7 additions & 1 deletion docs/examples/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ export default () => {
// }}
/>

<RangePicker {...sharedLocale} style={{ width: 400 }} allowEmpty />
<RangePicker
{...sharedLocale}
style={{ width: 400 }}
minDate={dayjs('2024')}
open
mode={['year', 'year']}
/>
{/* <SinglePicker
{...dateFnsSharedLocale}
style={{ width: 400 }}
Expand Down
2 changes: 1 addition & 1 deletion src/PickerPanel/DecadePanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function DecadePanel<DateType extends object = any>(
const [info] = useInfo(props, 'decade');

const getStartYear = (date: DateType) => {
const startYear = Math.floor(generateConfig.getYear(pickerValue) / 100) * 100;
const startYear = Math.floor(generateConfig.getYear(date) / 100) * 100;
return generateConfig.setYear(date, startYear);
};
const getEndYear = (date: DateType) => {
Expand Down
2 changes: 1 addition & 1 deletion src/PickerPanel/YearPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function YearPanel<DateType extends object = any>(
// ========================== Base ==========================
const [info] = useInfo(props, 'year');
const getStartYear = (date: DateType) => {
const startYear = Math.floor(generateConfig.getYear(pickerValue) / 10) * 10;
const startYear = Math.floor(generateConfig.getYear(date) / 10) * 10;
return generateConfig.setYear(date, startYear);
};
const getEndYear = (date: DateType) => {
Expand Down
9 changes: 8 additions & 1 deletion tests/new-range.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ describe('NewPicker.Range', () => {
it('pass tabIndex', () => {
const { container } = render(
<div>
<DayRangePicker tabIndex={-1}/>
<DayRangePicker tabIndex={-1} />
</div>,
);

Expand Down Expand Up @@ -1255,6 +1255,13 @@ describe('NewPicker.Range', () => {
});
expect(onChange).toHaveBeenCalled();
});

it('should disabled super prev correctly', () => {
render(<DayRangePicker minDate={dayjs()} picker="year" open />);

// Expect super prev disabled
expect(document.querySelector('.rc-picker-header-super-prev-btn-disabled')).toBeDisabled();
});
});

it('double click now button', () => {
Expand Down