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

Add a Month picker & other fixes #1510

Merged
merged 17 commits into from
Jan 23, 2025

Conversation

haideralsh
Copy link
Contributor

@haideralsh haideralsh commented Jan 21, 2025

Description

  • Remove unused package
  • Reduce vertical padding in the Switcher
  • Bump react-datepicker
  • Add a month picker
  • changelog had two 11.0.0 entries
  • make the MonthPicker a standalone component
  • Restructure DatePicker directory
  • Improve the contribution guide
  • Limit React support to version 16 to 18
  • Remove ts-nocheck from the DateRange component

Changes include

  • breaking change: a change that is not backwards-compatible and/or changes current functionality
  • fix: a non-breaking change that solves an issue
  • feature: a non-breaking change that adds functionality
  • chore: contains no changes affecting the library, such as documentation or test updates

Feature checklist

  • Appropriate tests have been added
  • Documentation has been updated
  • Accessibility has been considered

@haideralsh haideralsh changed the title Improve datepicker with month and week selector Add a Month picker Jan 21, 2025
@haideralsh haideralsh force-pushed the improve-datepicker-with-month-and-week-selector branch from cae4b64 to 89806c0 Compare January 21, 2025 20:22

const DatePicker = forwardRef<unknown, DatePickerProps>(({ highlightDates, ...props }, datePickerRef) => {
const handleDownKey = () => {
console.log("inside the date picker");
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't forget to remove this

}: ReactDatePickerCustomHeaderProps & { locale?: string }) {
const { t } = useTranslation();

console.log(t("go to previous year"));
Copy link
Contributor

Choose a reason for hiding this comment

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

This one too

}: ReactDatePickerCustomHeaderProps & { locale?: string }) {
const { t } = useTranslation();

console.log(t("go to previous year"));
Copy link
Contributor

Choose a reason for hiding this comment

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

One more

placeholder: (inputProps && inputProps.placeholder) || defaultPlaceholder,
};

const customInput = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be defined outside of the component body?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it's valid to define elements inside of a component body so long as they need access to props/state. It's only components that shall not be defined inside components as far as I understand.

Copy link
Contributor

Choose a reason for hiding this comment

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

I could have sworn there was a React Rule about this, but I cannot find it. I thought the challenge with inline definitions like this was that you effectively recreate the component on each re-render?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's correct in the case of a component (function), however, I've seen many libraries defining elements (constants) inside component bodies.

I believe the issue with components inside components is that the state will be flushed at every re-render which can be problematic.

Edit: Actually I am not sure about this anymore. ChatGPT thinks both are ok, which I am 99% sure is not the case:
https://chatgpt.com/share/6791459f-ddd8-800a-859e-d12bad980a08

@jherdman
Copy link
Contributor

I'm a little worried about those unknowns floating around here. Can they be narrowed at all?

@haideralsh haideralsh changed the title Add a Month picker Add a Month picker & other fixes Jan 22, 2025
@haideralsh haideralsh force-pushed the improve-datepicker-with-month-and-week-selector branch from 96f35e2 to 9edc3ac Compare January 22, 2025 16:51
@haideralsh
Copy link
Contributor Author

I'm a little worried about those unknowns floating around here. Can they be narrowed at all?

We can narrow it down and I did in the most recent commit. I am worried that it might create breaking changes for people since it was unknown in the past. I am trying to balance correctness with backwards compatibility.

@haideralsh haideralsh force-pushed the improve-datepicker-with-month-and-week-selector branch from a696672 to bb1ccfe Compare January 22, 2025 21:15
@haideralsh haideralsh merged commit 753b50f into master Jan 23, 2025
4 checks passed
@haideralsh haideralsh deleted the improve-datepicker-with-month-and-week-selector branch January 23, 2025 15:21
Copy link

🎉 This PR is included in version 13.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants