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

Fix a couple of nits as a result of the a11y PR #429

Merged
merged 1 commit into from
Apr 10, 2017

Conversation

majapw
Copy link
Collaborator

@majapw majapw commented Apr 7, 2017

  • blur the CalendarDay is month navigation was done with the mouse
  • prevent home/end/pagedown/pageup from scrolling the page
  • fixed some weirdness with the aria-label text on Calendar Day components when not using the DRP explicitly

to: @airbnb/webinfra @moonboots

@majapw majapw added the semver-patch: fixes/refactors/etc Anything that's not major or minor. label Apr 7, 2017
@majapw majapw force-pushed the maja-fix-tweaks-to-a11y-pr branch from 2f956c1 to 7f44e43 Compare April 7, 2017 21:02
@coveralls
Copy link

coveralls commented Apr 7, 2017

Coverage Status

Coverage decreased (-0.2%) to 83.554% when pulling 7f44e43 on maja-fix-tweaks-to-a11y-pr into 289dcc3 on master.

}, () => {
// we don't want to focus on the relevant calendar day after a month transition
// if the user is navigating around using a mouse
if (this.state.withMouseInteractions && document.activeElement) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should you check that document.activeElement is not the body?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would it cause a problem if it was?

Copy link
Member

Choose a reason for hiding this comment

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

Should this also check for document?

Copy link
Contributor

Choose a reason for hiding this comment

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

document.activeElement is the body by default. So when you blur, it gets set to the body. So this will end up blurring on the body every time. Probably not a big deal, but it is possible that this could kick off event listeners or other side-effects, depending on what has been registered on the page. Something like this might work? (not sure about browser support of HTMLBodyElement off the top of my head though)

!(document.activeElement instanceof HTMLBodyElement)

Copy link
Contributor

Choose a reason for hiding this comment

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

or I guess more simply

document.activeElement !== document.body

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll add the check, although this is somewhat of an extreme edge case given the way the datepicker is managing focus.

Basically, the setState that this is a callback of triggers a series of events that always ends in a CalendarDay being focused. So while it is possible that the user could blur between the componentDidUpdate call that focuses the CalendarDay in that leaf node and this setState callback 4 levels up in the tree, it's highly unlikely.

@coveralls
Copy link

coveralls commented Apr 7, 2017

Coverage Status

Coverage decreased (-0.2%) to 83.554% when pulling 7f44e43 on maja-fix-tweaks-to-a11y-pr into 289dcc3 on master.

@@ -301,10 +305,12 @@ export default class DayPicker extends React.Component {
didTransitionMonth = this.maybeTransitionPrevMonth(newFocusedDate);
break;
case 'Home':
if (e) e.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious when there will not be an e object in an event handler?

(it's probably best to keep this as-is, ofc, for consistency with the rest of the branches; and removing the if in the other branches would be semver-major, but i'd like to see us do that in the future)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mostly for testing purposes, which like, could be done better. I can remove these in another PR.

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, let's do that - we can pass { preventDefault() {} } in tests if needed.

}, () => {
// we don't want to focus on the relevant calendar day after a month transition
// if the user is navigating around using a mouse
if (this.state.withMouseInteractions && document.activeElement) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this also check for document?

@majapw majapw force-pushed the maja-fix-tweaks-to-a11y-pr branch 2 times, most recently from ef54e2b to 2e6f4a0 Compare April 7, 2017 21:53
@majapw
Copy link
Collaborator Author

majapw commented Apr 7, 2017

I also fixed some weirdness that I had not fully thought through with the phrases when it came to non-drp usage! PTAL @lencioni @ljharb

@coveralls
Copy link

coveralls commented Apr 7, 2017

Coverage Status

Coverage decreased (-0.08%) to 83.662% when pulling 2e6f4a0 on maja-fix-tweaks-to-a11y-pr into 289dcc3 on master.

@majapw majapw force-pushed the maja-fix-tweaks-to-a11y-pr branch from 2e6f4a0 to 615d4c0 Compare April 7, 2017 22:13
@coveralls
Copy link

coveralls commented Apr 7, 2017

Coverage Status

Coverage decreased (-0.08%) to 83.662% when pulling 615d4c0 on maja-fix-tweaks-to-a11y-pr into 289dcc3 on master.

@coveralls
Copy link

coveralls commented Apr 7, 2017

Coverage Status

Coverage decreased (-0.08%) to 83.662% when pulling 615d4c0 on maja-fix-tweaks-to-a11y-pr into 289dcc3 on master.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

LGTM, but it'd be nice not to drop test coverage ಠ_ಠ

@@ -102,8 +102,7 @@ export default class CalendarDay extends React.Component {
const formattedDate = `${day.format('dddd')}, ${day.format('LL')}`;

let ariaLabel = getPhrase(chooseAvailableDate, {
checkin_date: formattedDate,
checkout_date: formattedDate,
date: formattedDate,
Copy link
Member

Choose a reason for hiding this comment

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

is this a bugfix, or semver-major?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bugfix i'll say.

@@ -1,6 +1,8 @@
import React from 'react';

export default function getPhrase(phrase, args) {
if (!phrase) return '';
Copy link
Member

Choose a reason for hiding this comment

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

tests for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I should
probably write some tests
sigh

- blur the CalendarDay is month navigation was done with the mouse
- prevent home/end/pagedown/pageup from scrolling the page
- fixed some weirdness with the aria-label text on Calendar Day components when not using the DRP explicitly
@majapw majapw force-pushed the maja-fix-tweaks-to-a11y-pr branch from 615d4c0 to 311fec3 Compare April 10, 2017 17:03
@coveralls
Copy link

coveralls commented Apr 10, 2017

Coverage Status

Coverage decreased (-0.03%) to 83.716% when pulling 311fec3 on maja-fix-tweaks-to-a11y-pr into 289dcc3 on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch: fixes/refactors/etc Anything that's not major or minor.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants