react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

fix useRangeCalendar behavior while interacting outside

Open QzCurious opened this issue 2 years ago • 10 comments

Closes #5703, #5709

This is a proposal to fix useRangeCalendar behavior by directly showcasing what was wrong (IMO). Most problem were state on #5703. But I just can't state the issue any better. This PR would hopefully make things more clear.

✅ Pull Request Checklist:

  • [x] Included link to corresponding React Spectrum GitHub Issue.
  • [x] Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • [x] Filled out test instructions.
  • [ ] Updated documentation (if it already exists for this component).
  • [ ] Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

The videos is recorded with existing story.

The main difference is instead of commit selection, I canceled it. And canceling means that onChange would not get called.

Difference Original My Proposal
Click on empty cell, td, title of calendar or anywhere outside
Scrolling start on empty cell, td, title of calendar (or anywhere outside the calendar) should not affect selection
Drag onto empty cell, td, title of calendar or anywhere outside
Remain the same Original My Proposal
Scrolling start on a CalendarCell
Change viewport by navigation buttons
Select range by dragging

🧢 Your Project:

https://github.com/QzCurious/react-spectrum

QzCurious avatar Jan 19 '24 16:01 QzCurious

I don't know why but it seems like there were a few test case failed on commits before my.

QzCurious avatar Jan 19 '24 17:01 QzCurious

I've signed Adobe CLA and made CI running. Did "updated behavior" mean the code I submitted? If so, could you point me which test cases should I take care of?

It's currently too many tests failed on my machine (node v18.18.2 on commit ee51290b9). image

I'm not sure these test cases were "correctly failing" or caused by my environment. image

QzCurious avatar Jan 20 '24 18:01 QzCurious

@QzCurious Could you try node version v18.17.1? Some versions of node had a breaking change to Date/Time formatting, might be what you are running into here

LFDanLu avatar Jan 24 '24 00:01 LFDanLu

It works on v18.12.1 rather.

image


The relevant failed cases are:

  • releasing drag outside calendar commits it
  • clicking outside calendar commits selection
  • selects the nearest available date when blurring the calendar

And I've changed those to match new behavior:

  • cancel ongoing selection when releasing drag outside calendar
  • cancel ongoing selection when clicking outside calendar
  • cancel ongoing selection when blurring the calendar

QzCurious avatar Jan 24 '24 15:01 QzCurious

By the way, v18.17.1 works on a windows machine.


On my mac book, there are other failed tests. Seems like some were caused by encoding. And some might be platform specific.

The output text here

Colored output here

Screenshot 2024-01-24 at 11 09 55 PM Screenshot 2024-01-24 at 11 10 05 PM Screenshot 2024-01-24 at 11 10 17 PM Screenshot 2024-01-24 at 11 10 30 PM

QzCurious avatar Jan 24 '24 15:01 QzCurious

GET_BUILD

reidbarber avatar Jan 31 '24 17:01 reidbarber

Hi, just wanted to know how it goes. Let me know if there's anything I can help with.

QzCurious avatar Feb 17 '24 08:02 QzCurious

@QzCurious apologies, we've got a bit side tracked with last release, I'll see if we can get this into an upcoming testing session for the team to evaluate the new behavior.

LFDanLu avatar Feb 20 '24 18:02 LFDanLu

GET_BUILD

LFDanLu avatar Feb 23 '24 19:02 LFDanLu

## API Changes

unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any', access: 'private' } unknown top level export { type: 'any', access: 'private' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'identifier', name: 'Column' } unknown top level export { type: 'identifier', name: 'Column' } unknown type { type: 'link' } unknown type { type: 'link' } unknown type { type: 'link' } unknown type { type: 'link' } unknown type { type: 'link' } unknown type { type: 'link' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' } unknown top level export { type: 'any' }

rspbot avatar Feb 23 '24 19:02 rspbot

@QzCurious apologies about the delay, but the team went through the behavioral changes in a testing session today. Overall, we liked the update in behavior that allows the user to now scroll through multiple calendars and finalize a range selection. However, we weren't sure about completely canceling the range selection upon clicking outside the calendar, namely because of a flow where the user might assume that their selection has been made and then they click on an accompanying TimeField to continue configuring their date as shown here:

https://github.com/adobe/react-spectrum/assets/9661127/6eff20f1-2a2c-4f8b-8993-14acc11db2e6

with the new changes that would get canceled:

https://github.com/adobe/react-spectrum/assets/9661127/0dddab9f-eaf9-40c5-ae70-c99df0ec5fcd

LFDanLu avatar Feb 27 '24 00:02 LFDanLu

I understand there should have some effort for validating all possible scenarios. And im gald you found a "behavioral bug" for my change.

I'd love to ask if you team would have a plan to sort it all and implement it (because it actually involve some decisions instead of just a bug). Or I could still submit some progress, if any, for you to validate it.

By the way

For scroll through calendars, first recording is wrong. You should validating it on mobile interface (you can refer to the videos on https://github.com/adobe/react-spectrum/pull/5721#issue-2090932074).

QzCurious avatar Feb 27 '24 05:02 QzCurious

From the team's discussion yesterday, we'd be happy to accept a change isolated to fixing the mobile scrolling range selection but it was hard to tell from a glance if that would be easy to pull out from the changes made in this PR. Would that be possible?

For scroll through calendars, first recording is wrong. You should validating it on mobile interface (you can refer to the videos on https://github.com/adobe/react-spectrum/pull/5721#issue-2090932074).

As for the first recording, that is intentionally showing the desktop behavioral change rather than the mobile behavior. We were concerned that the changes may be confusing to a user using the RSP DateRangePicker because the flow shown in the first video here used to allow a user to confirm a date range selection when they click into the neighboring TimeField but that wouldn't happen after these changes in the PR.

LFDanLu avatar Feb 27 '24 18:02 LFDanLu

I see. Thanks for explaining it!

Let me know if you want keep these PR and issues open, or I will close this PR and related issues. And open an issue for "mobile scrolling range selection".

QzCurious avatar Feb 28 '24 03:02 QzCurious

Feel free to close them and open a new issue!

LFDanLu avatar Feb 28 '24 18:02 LFDanLu

Close.

Summery

  1. This PR is doing two things
    • Cancel ongoing selection when xxx, instead of select range on blur (see https://github.com/adobe/react-spectrum/pull/5721#issuecomment-1908310751)
    • Allow (mobile) scroll through multiple calendars and finalize a range selection (see https://github.com/adobe/react-spectrum/pull/5721#issue-2090932074: Scrolling start on empty cell, td, title of calendar)
  2. This PR would break an expected behavior, a UI that combing a calendar and a TimeFile (see: https://github.com/adobe/react-spectrum/pull/5721#issuecomment-1965572524)
  3. It's preferable to only have "mobile scrolling range selection" fixed without breaking existing "select range on blur".

QzCurious avatar Feb 29 '24 03:02 QzCurious