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

RangeCalendar visually showing selected day from previous month

Open ruijdacd opened this issue 3 years ago โ€ข 3 comments

๐Ÿ› Bug Report

When using the RangeCalendar component, when selecting a date in for example the month of July and then moving to next month, the component will visually present a range already selected until that day.

๐Ÿค” Expected Behavior

When navigating to other months, the user shouldn't be presented with a selected range of days, unless both dates are selected.

๐Ÿ˜ฏ Current Behavior

If selecting a date for example 14th of July, and then moving to August it will show that the range from 1st till 14th as selected).

๐Ÿ’ Possible Solution

๐Ÿ”ฆ Context

๐Ÿ’ป Code Sample

Example on react spectrum page for RangeCalendar component.

๐ŸŒ Your Environment

Software Version(s)
react-spectrum
Browser
Operating System

๐Ÿงข Your Company/Team

๐Ÿ•ท Tracking Issue (optional)

ruijdacd avatar Jul 06 '22 10:07 ruijdacd

This is intentional behavior, the RangeCalendar displays a "selected" range when moving to different months as a visual affordance reminding the user that a range selection is in progress.

LFDanLu avatar Jul 12 '22 16:07 LFDanLu

I see. Is there any way to differentiate that from when there is a selection in place?

Perhaps it would be nice to offer isHighlighted, so that we can apply a different style to those dates to better differentiate from the selected state.

const { isSelected, isHighlighted } = useCalendarCell();

ruijdacd avatar Jul 13 '22 09:07 ruijdacd

You could check to see if state.anchorDate is set. If so, it means that a selection is in progress.

devongovett avatar Jul 27 '22 00:07 devongovett

Sorry for the delayed response firstly, and thank you for your help!

I'll play around with this and see how beneficial it is to forcefully remove the visual guidance when selecting a range.

ruijdacd avatar Aug 26 '22 13:08 ruijdacd