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

Auto-focus the notification banner, add tests #1994

Merged
merged 2 commits into from
Oct 29, 2020

Conversation

hannalaakso
Copy link
Member

@hannalaakso hannalaakso commented Oct 22, 2020

This PR:

  • Auto-focuses the notification banner when the page loads if it has role="alert" and adds tabindex="1" so it can be fosused.
  • Tests the auto-focus behaviour:
    • If a notification banner has role=alert, it should receive tabindex="1" so it can be focused with JavaScript and the keyboard focus should move to it on page load
    • If a notification banner has the data-disable-auto-focus attribute, or it doesn't have role="alert" it should not have a tabindex or be focused

Tested in:
✅ Chrome 86 (Mac)
✅ Firefox 81 (Mac)
✅ Safari 14 (Mac)
✅ Galaxy S20 (Android 10)
✅ Galaxy Note 10 (Android 9)
✅ iPhone XS 12
✅ IE11
✅ IE10
✅ IE9
✅ IE8

Addresses part of #1935

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1994 October 22, 2020 17:24 Inactive
@hannalaakso hannalaakso force-pushed the add-notifications-auto-focus branch from 2abb78c to b84d8c2 Compare October 22, 2020 17:47
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1994 October 22, 2020 17:47 Inactive
@hannalaakso hannalaakso force-pushed the add-notifications-auto-focus branch from b84d8c2 to ac4831d Compare October 26, 2020 09:54
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1994 October 26, 2020 09:54 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1994 October 26, 2020 15:56 Inactive
@hannalaakso hannalaakso marked this pull request as ready for review October 26, 2020 16:00
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1994 October 27, 2020 16:41 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1994 October 27, 2020 17:03 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1994 October 28, 2020 18:33 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1994 October 28, 2020 18:37 Inactive
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

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

Looking really good – just a couple of minor comments 👍🏻

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-1994 October 29, 2020 16:39 Inactive
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

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

👏🏻

If a notification banner has `role="alert”`, add tabindex=“-1” to it so it can be focused and move keyboard focus to it with JavaScript for increased visibility to assistive technologies.

Don’t focus the banner if it has the data-disable-auto-focus attribute.
Test if the element has the correct tabindex and can be focused.

Test that element is not focused if it has the data-disable-auto-focus
attribute or it doesn’t have role=alert.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

4 participants