-
Notifications
You must be signed in to change notification settings - Fork 150
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(blade): focus on selected date by default in datepicker #2567
Conversation
🦋 Changeset detectedLatest commit: b82c1eb The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ PR title follows Conventional Commits specification. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit b82c1eb:
|
Bundle Size ReportUpdated Components
|
@@ -64,7 +66,18 @@ const Calendar = <Type extends DateSelectionType>({ | |||
|
|||
const dateContext = useDatesContext(); | |||
const isMobile = useIsMobile(); | |||
const currentDate = _date ?? shiftTimezone('add', new Date()); | |||
const currentDate = React.useMemo(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain whats happening here? the date
prop as is should work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are already using dateProp. Currently, _date is passed to Date.
Whenever the user clicks on the next month/year, we update _date, and the date picker focuses on _date.
I modified this logic slightly:
- If _date exists, focus on it.
- Otherwise, focus on oldValue.
- If oldValue is also unavailable, focus on currentDate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is oldValue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the last applied value in the date picker.
Whenever you click/select any value on the date picker, its value changes. But if you click on Cancel, we revert back to the older value using oldValue. When you click on Apply, we save the applied value in oldValue to retrieve it next time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM, Add interaction tests
Description
ref
Changes
Additional Information
Component Checklist