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: datepicker onchange trigger issue #16202

Conversation

riddhybansal
Copy link
Contributor

@riddhybansal riddhybansal commented Apr 15, 2024

Closes #16125
Closes #13128
Closes #15925
Closes #14047
Closes #14465

When clicking outside a DatePickerInput (after having already set a date previously) the on Change handler fires with unexpected dates in the payload of the handler.

Changelog

Changed

  • set the allowInput prop on DatePicker to false

Testing / Reviewing

  • set two dates with the datepicker.

  • click again on one of the inputs to open the calendar

  • click outside or click on another form element or tab away, Dates should be unchanged .

Copy link

netlify bot commented Apr 15, 2024

Deploy Preview for v11-carbon-react ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit b6cec32
🔍 Latest deploy log https://app.netlify.com/sites/v11-carbon-react/deploys/663b4191da99e50008032d3b
😎 Deploy Preview https://deploy-preview-16202--v11-carbon-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@riddhybansal
Copy link
Contributor Author

Using allow input will restrict user for inputing dates without calendars and may led to many a11y issues. The actual issue was in range plugin. From and to dates are not correctly fetched from the flatpicker configs , resulting in formating of dates.

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

@riddhybansal This looks great! Could a unit test be added to ensure this continues to work as expected in the future?

Copy link
Member

@alisonjoseph alisonjoseph left a comment

Choose a reason for hiding this comment

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

LGTM after test is added!

@riddhybansal riddhybansal requested a review from a team as a code owner May 7, 2024 15:37
@riddhybansal riddhybansal requested a review from guidari May 7, 2024 15:37
Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

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

Hey Riddhi! The fix LGTM!

Just one comment regarding the test case.

I was testing the current version and the bug happens on this sequence:
1 - The user will add a start and end date
2 - Datepicker has to be closed after the user click in the document.body to remove the focus from the component.
3 - The user have to place the focus again in the Datepicker by clicking on the start or end date and the Datepicker will open
4 - Repeat step 2 and the bug will happen

Maybe if you add a step to return focus to one of the inputs before simulate a click, it will cover the bug.

Copy link
Contributor

@guidari guidari left a comment

Choose a reason for hiding this comment

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

LGTM!

@riddhybansal riddhybansal added this pull request to the merge queue May 8, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 8, 2024
@riddhybansal riddhybansal added this pull request to the merge queue May 8, 2024
Merged via the queue into carbon-design-system:main with commit 4c0d5a1 May 8, 2024
20 checks passed
@riddhybansal riddhybansal deleted the Date_Picker_Onchange_Error branch May 8, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment