Skip to content

Commit

Permalink
fix: year lock
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Nov 13, 2024
1 parent b2ca430 commit 295d4db
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
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

0 comments on commit 295d4db

Please sign in to comment.