@financial-times/o-header
Advanced tools
Comparing version 8.3.0 to 8.3.1
@@ -20,21 +20,2 @@ "use strict"; | ||
// Some assistive technologies, like screen readers, suggest to press 'space' | ||
// when interacting with a link with a role of 'button'. | ||
// We need to ensure that we replicate this functionality that exists on a button element. | ||
// In the future we should consider using the 'button' element instead. | ||
function handleSpaceKeydown(e) { | ||
// get the target element | ||
var target = e.target; | ||
var targetIsRoleButton = target.getAttribute('role') === 'button'; // if the pressed key is a space, we'll simulate a click | ||
var keyPressIsSpace = e.keyCode === 32; | ||
if (targetIsRoleButton && keyPressIsSpace) { | ||
// prevent space from scrolling the page | ||
e.preventDefault(); // trigger the target's click event | ||
target.click(); | ||
} | ||
} | ||
class Header { | ||
@@ -64,3 +45,2 @@ constructor(headerEl) { | ||
headerEl.addEventListener('keydown', handleSpaceKeydown); | ||
this.headerEl.removeAttribute('data-o-header--no-js'); | ||
@@ -67,0 +47,0 @@ this.headerEl.setAttribute('data-o-header--js', ''); |
@@ -28,3 +28,3 @@ { | ||
"name": "@financial-times/o-header", | ||
"version": "8.3.0", | ||
"version": "8.3.1", | ||
"dependencies": { | ||
@@ -31,0 +31,0 @@ "@financial-times/o-colors": "^5.0.0", |
@@ -7,20 +7,2 @@ import search from './search'; | ||
// Some assistive technologies, like screen readers, suggest to press 'space' | ||
// when interacting with a link with a role of 'button'. | ||
// We need to ensure that we replicate this functionality that exists on a button element. | ||
// In the future we should consider using the 'button' element instead. | ||
function handleSpaceKeydown (e) { | ||
// get the target element | ||
const target = e.target; | ||
const targetIsRoleButton = target.getAttribute('role') === 'button'; | ||
// if the pressed key is a space, we'll simulate a click | ||
const keyPressIsSpace = e.keyCode === 32; | ||
if (targetIsRoleButton && keyPressIsSpace) { | ||
// prevent space from scrolling the page | ||
e.preventDefault(); | ||
// trigger the target's click event | ||
target.click(); | ||
} | ||
} | ||
class Header { | ||
@@ -47,4 +29,2 @@ | ||
headerEl.addEventListener('keydown', handleSpaceKeydown); | ||
this.headerEl.removeAttribute('data-o-header--no-js'); | ||
@@ -51,0 +31,0 @@ this.headerEl.setAttribute('data-o-header--js', ''); |
108040
996