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

🐛 Resolve the double-click focus issue of Time input and custom time component example #31

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

balajis-qb
Copy link
Collaborator

Closes Hacker0x01#4949

The Issue:

As I mentioned in the ticket, the issue is with the Time Input of the React Date Picker (both with the default Time Input - showTimeInput with shouldCloseOnSelect turned off and the Custom Time Input - customInput)
image

The issue is whenever we open the datepicker for the first time, and try to change the time before changing the date, now the time input won't get the focus and we need to do double click to get the focus. Then onwards, single click itself will bring the focus. The issue occurs only for the first update.

Why the issue occurs?

We are getting the issue because whenever we open the date picker, we auto-focus the selected date or the current date by setting it's tabIndex to 0 and all the other element's tab-index to -1. As a result we need to get the focus on other elements we need to click it twice. For all the other elements in the project, this case was handled by the manual highlight.

The Fix

I fixed the issue by manually setting the focus to the element whenever the time input got clicked and updated the corresponding test-cases.

Contribution checklist

  • I have followed the contributing guidelines.
  • 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.

…onent example

- Manually trigger focus on Time input when received the click event to override the default behavior of the selected date tabIndex 0
@balajis-qb balajis-qb merged commit 5221ac6 into main Sep 16, 2024
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom time input needs 2 clicks to focus
1 participant