Skip to content

Conversation

joaoGabriel55
Copy link
Contributor

What does this PR do?

Fixed issue #6150 which consists of when the user types in a date that is outside of the bounds (instead of using the calendar) and then brings up the calendar, sometimes the calendar forward/backward arrows are disabled if the date is in a month that is outside the bounds.

Where should the reviewer start?

Just access the Storybook story section, the second example.

localhost:9001/?path=/story/input-dateinput-format-inline--format-inline

What testing has been done on this PR?

How should this be manually tested?

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

No

What are the relevant issues?

No

Screenshots

image

image

Do the grommet docs need to be updated?

No

Should this PR be mentioned in the release notes?

No

Is this change backwards compatible or is it a breaking change?

No

@amandadupell
Copy link
Contributor

just some comments and behavior i noticed when testing:

the bounds is 07/02/2020 to 07/31/2020:
https://user-images.githubusercontent.com/38971752/172251144-6ea674d3-2599-4414-84da-7bbc5bedd608.mov

when i input 01/01/2020, the next arrow is not disabled as expected. however, i was a bit confused when i hit the arrow and it immediately jumped to 07/01/2020. in my mind, the next arrow would take me to 02/01/2020 where all of the dates would still be disabled and the next arrow button would still not be disabled, allowing me to move to the next date until i am in bounds.

with the voiceover buttons currently, it announces when a user focuses on the next button "move to february 2020" which aligns with the above expectations. we would need to update this in some way to allow users with assistive technology to understand the sudden jump.

i think that jumping to the dates in bounds can be a little jarring but is an understandable approach. @jcfilben thoughts?

@jcfilben
Copy link
Collaborator

jcfilben commented Jun 7, 2022

i think that jumping to the dates in bounds can be a little jarring but is an understandable approach. @jcfilben thoughts?

I agree, the behavior is confusing. In all other cases the left and right arrows on the calendar are moving by 1 month so having the same button move us by multiple months is a bit jarring.

However, I can see the reasoning for doing this. If a user selects a date that is way outside of the bounds then getting back could take a lot of clicks. However, in this case I think the user would likely just re-enter a new date into the date input if they are found outside the bounds.

For now I am leaning towards having the left and right button continue to advance or move back by 1 month if the date is out of bounds, but I am open to discussion on this if anyone else has thoughts.

@jcfilben
Copy link
Collaborator

Hey @joaoGabriel55 I just chatted about this with another member of the team and we are in agreement that the left and right arrows should advance or move back by 1 month instead of jumping backwards or forwards to a date that is within bounds. This will keep the arrow button behavior consistent so that we don't confuse users. Let us know if this sounds okay or if there are any objections.

@joaoGabriel55
Copy link
Contributor Author

Hey @joaoGabriel55 I just chatted about this with another member of the team and we are in agreement that the left and right arrows should advance or move back by 1 month instead of jumping backwards or forwards to a date that is within bounds. This will keep the arrow button behavior consistent so that we don't confuse users. Let us know if this sounds okay or if there are any objections.

I think that makes sense. I can provide some solution tomorow @jcfilben.

@joaoGabriel55 joaoGabriel55 force-pushed the fix/date-input-calendar-next-back-arrows-disabled-when-date-is-out-of-bounds branch from 798030a to c08641f Compare June 14, 2022 16:58
Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Coming along nicely! Just a few comments...
Also it looks like 2 of the calendar tests aren't passing

Comment on lines +700 to +704
disabled={disabledCalendarPreviousMonthButton(
previousMonth,
reference,
bounds,
)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
disabled={disabledCalendarPreviousMonthButton(
previousMonth,
reference,
bounds,
)}
disabled={!betweenDates(previousMonth, bounds) &&
(reference && bounds[1]
? !sameDayOrAfter(reference, new Date(bounds[1]))
: true)
}

Could we remove disabledCalendarPreviousMonthButton and simplify to something like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @jcfilben. I am using the methods disabledCalendarPreviousMonthButton and disabledCalendarNextMonthButton to keep disabled one of the change month buttons when the current month is a boundary. And keep not disabled their buttons when a month is out of bounds.

Examples:

image

image

image

Was I clear? I can try to explain it in another way.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah that makes sense, I think

disabled={!betweenDates(previousMonth, bounds) &&
                (reference && bounds[1]
                  ? !sameDayOrAfter(reference, new Date(bounds[1]))
                  : true)
              }

and

disabled={!betweenDates(nextMonth, bounds) &&
                (reference && bounds[0]
                  ? !sameDayOrBefore(reference, new Date(bounds[0]))
                  : true)
              }

are achieving the same behavior (but I could be missing something?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. The differences between checkers are only the bounds item passed and the sameDayOrAfter/Before validation, used to make one of the month change buttons disabled when end-users are in the first month of the bounds or in the last month of the bounds.

Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

I think the tests added in this PR just need fixed (they are failing on circle ci) and then the bundlesize increase (this can be done in the package.json under bundlesize: { maxSize: }) and then this is ready

@jcfilben jcfilben added the waiting Awaiting response to latest comments label Jul 18, 2022
@jcfilben
Copy link
Collaborator

Hey @joaoGabriel55! I just wanted to check in on this PR, and see if you're still interested in working on this or if you had any questions. I think it is super close to being done!

@joaoGabriel55
Copy link
Contributor Author

joaoGabriel55 commented Sep 22, 2022

Hey @joaoGabriel55! I just wanted to check in on this PR, and see if you're still interested in working on this or if you had any questions. I think it is super close to being done!

@jcfilben, I updated my current branch, I hope that pipeline does not fail.

Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks for working on this

@jcfilben jcfilben removed the waiting Awaiting response to latest comments label Sep 26, 2022
Brittany Archibeque and others added 2 commits November 8, 2022 13:11
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.

5 participants