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: Correct the typo in method name #4369

Closed
wants to merge 5 commits into from
Closed
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
46 changes: 45 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,65 @@ assignees: ""
---

## Description
**Linked issue**: #(issue number)

<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated


<<<<<<< HEAD

**Linked issue**: #(issue number)

**Problem**

<!-- The problems this PR aims to solve -->

**Changes**

<!-- Changes you have made to address the issue -->

## Screenshots

<!-- If applicable, add screenshots to help explain your improvements -->

## To reviewers

<!-- Additional comments for reviewers -->

## Contribution checklist

=======
**Linked issue**: #(issue number)
=======

**Linked issue**: #(issue number)

> > > > > > > 7e348685d1d307afea97a9c840201a22f2fd8df2

**Problem**

<!-- The problems this PR aims to solve -->

**Changes**

<!-- Changes you have made to address the issue -->

## Screenshots

<!-- If applicable, add screenshots to help explain your improvements -->

## To reviewers

<!-- Additional comments for reviewers -->

## Contribution checklist

<<<<<<< HEAD

> > > > > > > 0ca150d3532664bfaa12c30e0c5a4e6cf4fee0ab

=======

> > > > > > > 7e348685d1d307afea97a9c840201a22f2fd8df2

- [ ] I have followed the [contributing guidelines](https://github.com/Hacker0x01/react-datepicker/blob/main/CONTRIBUTING.md).
- [ ] I have added sufficient test coverage for my changes.
- [ ] I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.
2 changes: 1 addition & 1 deletion src/date_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ export function getEffectiveMaxDate({ maxDate, includeDates }) {
}
}

export function getHightLightDaysMap(
export function getHighLightDaysMap(
highlightDates = [],
defaultClassName = "react-datepicker__day--highlighted",
) {
Expand Down
39 changes: 20 additions & 19 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
parseDate,
safeDateFormat,
safeDateRangeFormat,
getHightLightDaysMap,
getHighLightDaysMap,
getYear,
getMonth,
getStartOfWeek,
Expand Down Expand Up @@ -351,7 +351,7 @@ export default class DatePicker extends React.Component {
}
if (prevProps.highlightDates !== this.props.highlightDates) {
this.setState({
highlightDates: getHightLightDaysMap(this.props.highlightDates),
highlightDates: getHighLightDaysMap(this.props.highlightDates),
});
}
if (
Expand Down Expand Up @@ -381,10 +381,10 @@ export default class DatePicker extends React.Component {
this.props.openToDate
? this.props.openToDate
: this.props.selectsEnd && this.props.startDate
? this.props.startDate
: this.props.selectsStart && this.props.endDate
? this.props.endDate
: newDate();
? this.props.startDate
: this.props.selectsStart && this.props.endDate
? this.props.endDate
: newDate();

// Convert the date from string format to standard Date format
modifyHolidays = () =>
Expand All @@ -405,8 +405,8 @@ export default class DatePicker extends React.Component {
minDate && isBefore(defaultPreSelection, startOfDay(minDate))
? minDate
: maxDate && isAfter(defaultPreSelection, endOfDay(maxDate))
? maxDate
: defaultPreSelection;
? maxDate
: defaultPreSelection;
return {
open: this.props.startOpen || false,
preventFocus: false,
Expand All @@ -416,7 +416,8 @@ export default class DatePicker extends React.Component {
: this.props.selected) ?? boundedPreSelection,
// transforming highlighted days (perhaps nested array)
// to flat Map for faster access in day.jsx
highlightDates: getHightLightDaysMap(this.props.highlightDates),
highlightDates: getHighLightDaysMap(this.props.highlightDates),
holidays: getHolidaysMap(modifiedHolidays),
focused: false,
// used to focus day in inline version after month has changed, but not on
// initial render
Expand Down Expand Up @@ -1252,16 +1253,16 @@ export default class DatePicker extends React.Component {
typeof this.props.value === "string"
? this.props.value
: typeof this.state.inputValue === "string"
? this.state.inputValue
: this.props.selectsRange
? safeDateRangeFormat(
this.props.startDate,
this.props.endDate,
this.props,
)
: this.props.selectsMultiple
? safeMultipleDatesFormat(this.props.selectedDates, this.props)
: safeDateFormat(this.props.selected, this.props);
? this.state.inputValue
: this.props.selectsRange
? safeDateRangeFormat(
this.props.startDate,
this.props.endDate,
this.props,
)
: this.props.selectsMultiple
? safeMultipleDatesFormat(this.props.selectedDates, this.props)
: safeDateFormat(this.props.selected, this.props);

return React.cloneElement(customInput, {
[customInputRef]: (input) => {
Expand Down
9 changes: 6 additions & 3 deletions src/month.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -799,14 +799,17 @@ export default class Month extends React.Component {
onPointerLeave={
this.props.usePointerEvent ? this.handleMouseLeave : undefined
}
aria-label={`${formattedAriaLabelPrefix}${utils.formatDate(day, "MMMM, yyyy")}`}
aria-label={`${formattedAriaLabelPrefix}${utils.formatDate(
day,
"MMMM, yyyy",
)}`}
role="listbox"
>
{showMonthYearPicker
? this.renderMonths()
: showQuarterYearPicker
? this.renderQuarters()
: this.renderWeeks()}
? this.renderQuarters()
: this.renderWeeks()}
</div>
);
}
Expand Down
14 changes: 8 additions & 6 deletions test/day_test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
addDays,
subDays,
getMonth,
getHightLightDaysMap,
getHighLightDaysMap,
getHolidaysMap,
registerLocale,
} from "../src/date_utils";
Expand Down Expand Up @@ -221,7 +221,7 @@ describe("Day", () => {
const highlightDay1 = newDate(day);
const highlightDay2 = addDays(day, 1);
const highlightDates = [highlightDay1, highlightDay2];
const highlightDatesMap = getHightLightDaysMap(highlightDates);
const highlightDatesMap = getHighLightDaysMap(highlightDates);
const container = renderDay(day, { highlightDates: highlightDatesMap });
expect(
container
Expand All @@ -235,7 +235,7 @@ describe("Day", () => {
const highlightDay1 = subDays(day, 1);
const highlightDay2 = addDays(day, 1);
const highlightDates = [highlightDay1, highlightDay2];
const highlightDatesMap = getHightLightDaysMap(highlightDates);
const highlightDatesMap = getHighLightDaysMap(highlightDates);
const container = renderDay(day, { highlightDates: highlightDatesMap });
expect(
container
Expand All @@ -253,7 +253,7 @@ describe("Day", () => {
const highlightDay2 = addDays(day, 2);
const highlightDay3 = addDays(day, 3);
const highlightDates = [highlightDay1, highlightDay2, highlightDay3];
const highlightDatesMap = getHightLightDaysMap(highlightDates);
const highlightDatesMap = getHighLightDaysMap(highlightDates);
const container = renderDay(day, {
highlightDates: highlightDatesMap,
});
Expand All @@ -272,7 +272,8 @@ describe("Day", () => {
const highlightDay2 = addDays(day, 3);
const highlightDay3 = addDays(day, 4);
const highlightDates = [highlightDay1, highlightDay2, highlightDay3];
const highlightDatesMap = getHightLightDaysMap(highlightDates);

const highlightDatesMap = getHighLightDaysMap(highlightDates);
const container = renderDay(day, {
highlightDates: highlightDatesMap,
});
Expand All @@ -289,7 +290,8 @@ describe("Day", () => {
const highlightDay2 = { barClassName: [newDate(day)] };
const highlightDay3 = newDate(day);
const highlightDates = [highlightDay1, highlightDay2, highlightDay3];
const highlightDatesMap = getHightLightDaysMap(highlightDates);

const highlightDatesMap = getHighLightDaysMap(highlightDates);
const container = renderDay(day, {
highlightDates: highlightDatesMap,
});
Expand Down
12 changes: 8 additions & 4 deletions test/month_test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ describe("Month", () => {
<Month day={date} ariaLabelPrefix={ariaLabelPrefix} />,
);

const expectedAriaLabel =
`${ariaLabelPrefix} ${utils.formatDate(date, "MMMM, yyyy")}`.toLowerCase();
const expectedAriaLabel = `${ariaLabelPrefix} ${utils.formatDate(
date,
"MMMM, yyyy",
)}`.toLowerCase();
expect(
container
.querySelector(".react-datepicker__month")
Expand All @@ -85,8 +87,10 @@ describe("Month", () => {
<Month day={date} ariaLabelPrefix={ariaLabelPrefix} />,
);

const expectedAriaLabel =
`${utils.formatDate(date, "MMMM, yyyy")}`.toLowerCase();
const expectedAriaLabel = `${utils.formatDate(
date,
"MMMM, yyyy",
)}`.toLowerCase();
expect(
container
.querySelector(".react-datepicker__month")
Expand Down
Loading