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

fixes tabs keyboard navigation bug in IE8 #1359

Merged
merged 3 commits into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@

🔧 Fixes:

- fixes tabs keyboard navigation bug in IE8

Users were unable to tab between tab panels using the keyboard and had to
use their mouse to toggle between panels.

([PR #1359](https://github.com/alphagov/govuk-frontend/pull/1359))

- Update accordion focus styles to remove firefox outlines

([PR #1324](https://github.com/alphagov/govuk-frontend/pull/1324))
Expand Down
6 changes: 4 additions & 2 deletions src/components/tabs/tabs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import '../../vendor/polyfills/Function/prototype/bind'
import '../../vendor/polyfills/Element/prototype/classList'
import '../../vendor/polyfills/Element/prototype/nextElementSibling'
import '../../vendor/polyfills/Element/prototype/previousElementSibling'
import '../../vendor/polyfills/Event' // addEventListener and event.target normaliziation
import { nodeListForEach } from '../../common'

Expand Down Expand Up @@ -207,7 +209,7 @@ Tabs.prototype.activateNextTab = function () {
var currentTab = this.getCurrentTab()
var nextTabListItem = currentTab.parentNode.nextElementSibling
if (nextTabListItem) {
var nextTab = nextTabListItem.firstElementChild
var nextTab = nextTabListItem.querySelector('.govuk-tabs__tab')
}
if (nextTab) {
this.hideTab(currentTab)
Expand All @@ -221,7 +223,7 @@ Tabs.prototype.activatePreviousTab = function () {
var currentTab = this.getCurrentTab()
var previousTabListItem = currentTab.parentNode.previousElementSibling
aliuk2012 marked this conversation as resolved.
Show resolved Hide resolved
if (previousTabListItem) {
var previousTab = previousTabListItem.firstElementChild
var previousTab = previousTabListItem.querySelector('.govuk-tabs__tab')
}
if (previousTab) {
this.hideTab(currentTab)
Expand Down
27 changes: 27 additions & 0 deletions src/vendor/polyfills/Element/prototype/nextElementSibling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import '../../Object/defineProperty'
import '../../Element'

(function(undefined) {

// Detection from https://github.com/Financial-Times/polyfill-service/pull/1062/files#diff-b09a5d2acf3314b46a6c8f8d0c31b85c
var detect = (
'Element' in this && "nextElementSibling" in document.documentElement
)

if (detect) return


(function (global) {

// Polyfill from https://github.com/Financial-Times/polyfill-service/pull/1062/files#diff-404b69b4750d18dea4174930a49170fd
Object.defineProperty(Element.prototype, "nextElementSibling", {
get: function(){
var el = this.nextSibling;
while (el && el.nodeType !== 1) { el = el.nextSibling; }
return (el.nodeType === 1) ? el : null;
}
});

}(this));

}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
25 changes: 25 additions & 0 deletions src/vendor/polyfills/Element/prototype/previousElementSibling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import '../../Object/defineProperty'
import '../../Element'

(function(undefined) {

// Detection from https://github.com/Financial-Times/polyfill-service/pull/1062/files#diff-a162235fbc9c0dd40d4032265f44942e
var detect = (
'Element' in this && 'previousElementSibling' in document.documentElement
)

if (detect) return

(function (global) {
aliuk2012 marked this conversation as resolved.
Show resolved Hide resolved
// Polyfill from https://github.com/Financial-Times/polyfill-service/pull/1062/files#diff-b45a1197b842728cb76b624b6ba7d739
Object.defineProperty(Element.prototype, 'previousElementSibling', {
get: function(){
var el = this.previousSibling;
while (el && el.nodeType !== 1) { el = el.previousSibling; }
return (el.nodeType === 1) ? el : null;
}
});

}(this));

}).call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});