Skip to content

fix: disable tab for outside days (#1567)#1576

Merged
gpbl merged 8 commits into
gpbl:masterfrom
DanielJKelly:issue1567
Oct 9, 2022
Merged

fix: disable tab for outside days (#1567)#1576
gpbl merged 8 commits into
gpbl:masterfrom
DanielJKelly:issue1567

Conversation

@DanielJKelly

@DanielJKelly DanielJKelly commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

Context

Please see #1567 for more context about the issue this PR is meant to fix.

Analysis

The issue is that const isFocusTarget = Boolean(focusContext.focusTarget && isSameDay(focusContext.focusTarget, day)) will return true for multiple days if there is a day that is both "selected" and "outside".

If a day is both outside and selected, the equivalent "inside" day must also be present on one of the displayed calendars, so this day will receive tabIndex=0 and there is no need for the outside version of the day to have tabIndex=0.

Solution

Per the above analysis, my solution is to not consider a day with both the selected and outside active modifiers as a focus target, meaning the tabIndex will be set to -1.

@DanielJKelly DanielJKelly marked this pull request as ready for review October 7, 2022 17:39
@DanielJKelly

Copy link
Copy Markdown
Contributor Author

"If a day is both outside and selected, the equivalent "inside" day must also be present on one of the displayed calendars"

I just realized this is not true, whoops. Perhaps I could check if the day is within more than one displayed month 🤔

@DanielJKelly DanielJKelly changed the title fix: Set tabIndex to -1 when day is both outside and selected (#1567) fix: Set tabIndex to -1 when day is both outside and displayed (#1567) Oct 8, 2022
@DanielJKelly

Copy link
Copy Markdown
Contributor Author

"If a day is both outside and selected, the equivalent "inside" day must also be present on one of the displayed calendars"

I just realized this is not true, whoops. Perhaps I could check if the day is within more than one displayed month 🤔

I updated the PR to check if a day is both outside and displayed, which I think makes sense.

@gpbl

gpbl commented Oct 8, 2022

Copy link
Copy Markdown
Owner

Hey @DanielJKelly thanks for your PR, I've been investigating #1567 too and this one seems a good solution.

If a day is both outside and selected, the equivalent "inside" day must also be present on one of the displayed calendars,

I want to give a second look: I'm not 100% sure of this (yet) :)

focusContext.focusTarget && isSameDay(focusContext.focusTarget, day)
focusContext.focusTarget &&
isSameDay(focusContext.focusTarget, day) &&
!isOutsideAndDisplayed

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to check if the date is displayed or not. I'd just check the activeModifiers.outside.

Suggested change
!isOutsideAndDisplayed
!activeModifiers.outside

@gpbl

gpbl commented Oct 9, 2022

Copy link
Copy Markdown
Owner

@DanielJKelly Thanks for your investigation! I could review your PR and apply some changes:

  • disabled tabIndex for outside days
  • added an integration test for your use case

I think we should fix this in getInitialFocusTarget, but this function is not aware of the outside days yet.

What do you think? Am I missing something if we don't check "displayed days"?

@gpbl gpbl changed the title fix: Set tabIndex to -1 when day is both outside and displayed (#1567) fix: disable tab for outside days (#1567) Oct 9, 2022
@DanielJKelly

Copy link
Copy Markdown
Contributor Author

@DanielJKelly Thanks for your investigation! I could review your PR and apply some changes:

  • disabled tabIndex for outside days
  • added an integration test for your use case

I think we should fix this in getInitialFocusTarget, but this function is not aware of the outside days yet.

What do you think? Am I missing something if we don't check "displayed days"?

@gpbl Thanks for the feedback and making the changes. I think you are right that checking "displayed days" is unnecessary. I only added that extra check because I wasn't completely sure if there was some use case I was missing for having an outside day be focusable.

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.

Bug: Stuck in a focus loop trying to focus outside day

2 participants