Skip to content

Commit

Permalink
Fix primefaces#4578: Calendar overlay size should be based on origina…
Browse files Browse the repository at this point in the history
…l view
  • Loading branch information
melloware committed Jun 30, 2023
1 parent 735bd30 commit 9100dc6
Showing 1 changed file with 3 additions and 33 deletions.
36 changes: 3 additions & 33 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ export const Calendar = React.memo(
if (appendDisabled()) {
DomHandler.relativePosition(overlayRef.current, inputRef.current);
} else {
if (currentView === 'date') {
if (props.view === 'date') {
overlayRef.current.style.width = DomHandler.getOuterWidth(overlayRef.current) + 'px';
overlayRef.current.style.minWidth = DomHandler.getOuterWidth(inputRef.current) + 'px';
} else {
Expand Down Expand Up @@ -3033,37 +3033,6 @@ export const Calendar = React.memo(
return months;
};

const createMonthViewMonth = (index) => {
const className = classNames('p-monthpicker-month', { 'p-highlight': isMonthSelected(index), 'p-disabled': !isSelectable(0, index, currentYear) });
const monthNamesShort = localeOption('monthNamesShort', props.locale);
const monthName = monthNamesShort[index];
const monthProps = mergeProps(
{
className,
onClick: (event) => onMonthSelect(event, index),
onKeyDown: (event) => onMonthCellKeydown(event, index)
},
ptm('month')
);

return (
<span {...monthProps} key={monthName}>
{monthName}
<Ripple />
</span>
);
};

const createMonthViewMonths = () => {
let months = [];

for (let i = 0; i <= 11; i++) {
months.push(createMonthViewMonth(i));
}

return months;
};

const monthPickerValues = () => {
let monthPickerValues = [];
const monthNamesShort = localeOption('monthNamesShort', props.locale);
Expand Down Expand Up @@ -3586,7 +3555,8 @@ export const Calendar = React.memo(
const monthProps = mergeProps(
{
className: classNames('p-monthpicker-month', { 'p-highlight': isMonthSelected(i), 'p-disabled': !isSelectable(0, i, currentYear) }),
onClick: (event) => onMonthSelect(event, i)
onClick: (event) => onMonthSelect(event, i),
onKeyDown: (event) => onMonthCellKeydown(event, i)
},
ptm('month')
);
Expand Down

0 comments on commit 9100dc6

Please sign in to comment.