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

RangeCalendar: When one date selected #5456

Closed
thorbde opened this issue Nov 22, 2023 · 6 comments
Closed

RangeCalendar: When one date selected #5456

thorbde opened this issue Nov 22, 2023 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers RAC

Comments

@thorbde
Copy link

thorbde commented Nov 22, 2023

Provide a general summary of the issue here

When selecting a date in RangeCalendar, and not having moved the cursor yet, the one date that is in selection acts as a [data-selection-end]. This causes styling issues for us:
Screenshot 2023-11-22 at 10 38 54

🤔 Expected Behavior?

I expect this cell to act as a [data-selected] before the selection is extended, as React Aria can't predict which direction the user will drag the selection.

😯 Current Behavior

React Aria predicts that the cell should act as [data-selection-end]

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

Current CSS implementation:

&[data-selected] {
          color: INTERNAL COLOR VARIABLE;
          background: INTERNAL COLOR VARIABLE;

          &:hover {
            background: INTERNAL COLOR VARIABLE;
          }
        }
&[data-selection-start],
&[data-selection-end] {
          color: INTERNAL COLOR VARIABLE;
          /** This is to have two backgrounds, see screenshot above */
          &::after {
                    background: INTERNAL COLOR VARIABLE;
          }
}

Version

React-Aria-Components

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Microsoft Edge

If other, please specify.

No response

What operating system are you using?

MacOs Sonoma 14.0

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

@thorbde thorbde changed the title RangeCalnedar: When one date selected RangeCalendar: When one date selected Nov 22, 2023
@LFDanLu
Copy link
Member

LFDanLu commented Nov 22, 2023

We could perhaps change this line to have a && state.value != null check since I believe value is only defined once a range is fully selected:

isSelectionEnd = isSameDay(date, state.highlightedRange.end);

From a brief glance, this doesn't seem to break any of our existing styles

@LFDanLu LFDanLu added the enhancement New feature or request label Nov 22, 2023
@github-project-automation github-project-automation bot moved this to ✏️ To Groom in RSP Component Milestones Nov 22, 2023
@LFDanLu LFDanLu added RAC good first issue Good for newcomers labels Nov 22, 2023
@ananta
Copy link

ananta commented Dec 3, 2023

@LFDanLu I would love to work on this issue :)

@LFDanLu
Copy link
Member

LFDanLu commented Dec 5, 2023

@ananta sure, go for it!

@abdullahtariq1171
Copy link

I tried reproducing it but couldn't. Could you provide sandbox of your example? @thorbde

Here is my reproduction attempt https://codesandbox.io/p/sandbox/condescending-microservice-5j63r8

When selecting a date using cursor click, it returns {isSelected: true, isSelectionStart: true, isSelectionEnd: true} . This looks correct behavior to me since it automatically moves the selection to next date as end date.

and keyboard by pressing space, it returns {isSelected: true, isSelectionStart: true, isSelectionEnd: false}

cc: @LFDanLu

@LFDanLu
Copy link
Member

LFDanLu commented Apr 17, 2024

I believe @thorbde's original ask was for isSelectionEnd to be false on cursor click (and by extension data-selection-end would also be false). As you've noted above, a date currently has isSelectionEnd: true when first clicked. This might be a breaking change to make now though since RAC has been fully release though and people might be relying on the current behavior though...

@thorbde
Copy link
Author

thorbde commented Apr 17, 2024

@LFDanLu
You may close this issue, we were able to solve it for our use case

@thorbde thorbde closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2024
@github-project-automation github-project-automation bot moved this from ✏️ To Groom to ✅ Done in RSP Component Milestones Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers RAC
Projects
Archived in project
Development

No branches or pull requests

4 participants