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(blade): focus on selected date by default in datepicker #2567

Merged
merged 6 commits into from
Mar 12, 2025

Conversation

tewarig
Copy link
Contributor

@tewarig tewarig commented Mar 9, 2025

Description

ref

Changes

Additional Information

Component Checklist

  • Update Component Status Page
  • Perform Manual Testing in Other Browsers
  • Add KitchenSink Story
  • Add Interaction Tests (if applicable)
  • Add changeset

Copy link

changeset-bot bot commented Mar 9, 2025

🦋 Changeset detected

Latest commit: b82c1eb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@razorpay/blade Patch

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

Copy link
Contributor

github-actions bot commented Mar 9, 2025

✅ PR title follows Conventional Commits specification.

@tewarig tewarig changed the title Fix(blade): focus on selected date by default in datepicker fix(blade): focus on selected date by default in datepicker Mar 9, 2025
Copy link

codesandbox-ci bot commented Mar 9, 2025

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:

Sandbox Source
razorpay/blade: basic Configuration

@rzpcibot
Copy link
Collaborator

rzpcibot commented Mar 9, 2025

Bundle Size Report

Updated Components
Status Component Base Size (kb) Current Size (kb) Diff
MotionDiv -0.051 -0.049 +0.002 KB
DatePicker 87.225 87.278 +0.053 KB
Fade 1.046 1.045 -0.001 KB
TopNav, TopNavActions, TopNavBrand, TopNavContent 0.628 0.627 -0.001 KB

Generated by 🚫 dangerJS against b82c1eb

@tewarig tewarig marked this pull request as ready for review March 10, 2025 05:09
@tewarig tewarig added the P0 Critical label Mar 10, 2025
@@ -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(() => {
Copy link
Member

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?

Copy link
Contributor Author

@tewarig tewarig Mar 10, 2025

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:

  1. If _date exists, focus on it.
  2. Otherwise, focus on oldValue.
  3. If oldValue is also unavailable, focus on currentDate.

Copy link
Member

Choose a reason for hiding this comment

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

what is oldValue?

Copy link
Contributor Author

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.

anuraghazra
anuraghazra previously approved these changes Mar 11, 2025
Copy link
Member

@anuraghazra anuraghazra left a 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

@tewarig tewarig merged commit 1419c1f into master Mar 12, 2025
12 of 14 checks passed
@tewarig tewarig deleted the fix/focus-on-selected-value-by-default branch March 12, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P0 Critical
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants