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

Calendar logic #7642

Open
pan-alexey opened this issue Jan 21, 2025 · 4 comments
Open

Calendar logic #7642

pan-alexey opened this issue Jan 21, 2025 · 4 comments

Comments

@pan-alexey
Copy link

🙋 Documentation Request

In the process of developing a calendar implementation and using hooks useCalendar, some unclear cases arose.
When creating a hook:

const calendarAria = useCalendar(options, state);

in calendarAria.calendarProps there is an event that has an onBlur handler.
In the case of onBlur, it sets a value for the element that is in focus. Is this the correct behavior?

Image

🧢 Your Company/Team

No response

@reidbarber
Copy link
Member

This is used to stop range selection if you're starting to select a range, then tab away before selecting the end date:

// Also stop range selection on blur, e.g. tabbing away from the calendar.
res.calendarProps.onBlur = e => {
if (!ref.current) {
return;
}
if ((!e.relatedTarget || !ref.current.contains(e.relatedTarget)) && state.anchorDate) {
state.selectFocusedDate();
}
};

@LFDanLu LFDanLu added the waiting Waiting on Issue Author label Jan 21, 2025
@pan-alexey
Copy link
Author

Such behavior causes ambiguity, in the example from the video, if the user has chosen the start date, focused on the date in the process of choosing, and clicked on a blank field, the focus disappears and the selection is made. It is precisely a click that happens in the video.

Screen.Recording.2025-01-23.at.09.23.58.mov

@reidbarber reidbarber removed the waiting Waiting on Issue Author label Jan 24, 2025
@reidbarber
Copy link
Member

I see what you're saying. This looks pretty similar, but not exactly the same, to this issue: #3738

I think we could consider reverting to the previously selected range if this is the case. I forgot if there's a reason we did this, or if there are other considerations I'm not thinking of.

@pan-alexey
Copy link
Author

Continuing the discussion, I noticed another piece of code that is difficult to comprehend its purpose. The problem in my project is that if a user starts making a choice, at the onPointerUp event, a date also gets selected if there’s a tap on the screen.

Image
Screen.Recording.2025-02-06.at.16.45.18.mov

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

No branches or pull requests

3 participants