Skip to content

Commit

Permalink
fix: allow showWeek=false when picker=week (antd#50157)
Browse files Browse the repository at this point in the history
  • Loading branch information
liangjiajin committed Jul 31, 2024
1 parent b489cd3 commit 03a1b59
Showing 1 changed file with 35 additions and 36 deletions.
71 changes: 35 additions & 36 deletions src/PickerPanel/DatePanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,42 +51,41 @@ export default function DatePanel<DateType extends object = any>(props: DatePane
const month = generateConfig.getMonth(pickerValue);

// =========================== PrefixColumn ===========================
const prefixColumn =
isWeek || showWeek
? (date: DateType) => {
// >>> Additional check for disabled
const disabled = disabledDate?.(date, { type: 'week' });

return (
<td
key="week"
className={classNames(cellPrefixCls, `${cellPrefixCls}-week`, {
[`${cellPrefixCls}-disabled`]: disabled,
})}
// Operation: Same as code in PanelBody
onClick={() => {
if (!disabled) {
onSelect(date);
}
}}
onMouseEnter={() => {
if (!disabled) {
onHover?.(date);
}
}}
onMouseLeave={() => {
if (!disabled) {
onHover?.(null);
}
}}
>
<div className={`${cellPrefixCls}-inner`}>
{generateConfig.locale.getWeek(locale.locale, date)}
</div>
</td>
);
}
: null;
const prefixColumn = showWeek
? (date: DateType) => {
// >>> Additional check for disabled
const disabled = disabledDate?.(date, { type: 'week' });

return (
<td
key="week"
className={classNames(cellPrefixCls, `${cellPrefixCls}-week`, {
[`${cellPrefixCls}-disabled`]: disabled,
})}
// Operation: Same as code in PanelBody
onClick={() => {
if (!disabled) {
onSelect(date);
}
}}
onMouseEnter={() => {
if (!disabled) {
onHover?.(date);
}
}}
onMouseLeave={() => {
if (!disabled) {
onHover?.(null);
}
}}
>
<div className={`${cellPrefixCls}-inner`}>
{generateConfig.locale.getWeek(locale.locale, date)}
</div>
</td>
);
}
: null;

// ========================= Cells ==========================
// >>> Header Cells
Expand Down

0 comments on commit 03a1b59

Please sign in to comment.