-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix focus/click race condition on language dropdown (#286)
* Fix focus/click race condition on language dropdown * Fix language dropwdown unit tests * Fix unit tests in IE * Ensure linking to other pages works and give examples * Fix language unit tests
- Loading branch information
Showing
7 changed files
with
259 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default function triggerEvent(element, eventType) { | ||
let event; | ||
if (typeof Event === 'function') { | ||
event = new Event(eventType); | ||
} else { | ||
event = document.createEvent('Event'); | ||
event.initEvent(eventType, true, true); | ||
} | ||
|
||
element.dispatchEvent(event); | ||
} |
69 changes: 69 additions & 0 deletions
69
src/patterns/language-selection/examples/many-languages/cy.njk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
layout: none | ||
--- | ||
{% extends "styles/page-template/_template.njk" %} | ||
|
||
{% set page = { | ||
"title": "Enw'r gwasanaeth", | ||
"language": { | ||
"languages": [ | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages", | ||
"ISOCode": "en-GB", | ||
"text": "English", | ||
"buttonAriaLabel": "Language selector. Current language: English", | ||
"chooseLanguage": "Choose language", | ||
"current": false | ||
}, | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages/cy.html", | ||
"ISOCode": "cy", | ||
"text": "Cymraeg", | ||
"buttonAriaLabel": "Dewisydd iaith. Iaith gyfredol: Cymraeg", | ||
"chooseLanguage": "Dewiswch iaith", | ||
"current": true | ||
}, | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages/ga.html", | ||
"ISOCode": "ga", | ||
"text": "Gaeilge", | ||
"buttonAriaLabel": "Roghnóir teanga. Teanga reatha: Gaeilge", | ||
"chooseLanguage": "Roghnaigh teanga", | ||
"current": false | ||
}, | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages/sco.html", | ||
"ISOCode": "sco", | ||
"text": "Ulstèr-Scotch", | ||
"buttonAriaLabel": "Leid selectgor. Current leid: Ulstèr-Scotch", | ||
"chooseLanguage": "Wale leid", | ||
"current": false | ||
} | ||
] | ||
}, | ||
"footer": { | ||
"rows": [ | ||
{ | ||
"items": [ | ||
{ | ||
"text": "Cysyllwch a ni", | ||
"url": "#" | ||
}, | ||
{ | ||
"text": "Cwcis ac preifatrwydd", | ||
"url": "#" | ||
} | ||
] | ||
} | ||
], | ||
"OGLLink": { | ||
"pre": "Mae'r holl gynnwys ar gael o dan y", | ||
"link": "Drwydded Llywodraeth Leol v3.0", | ||
"url": "https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/", | ||
"post": ", oni bai y nodir fel arall" | ||
} | ||
} | ||
} %} | ||
|
||
{% block content %} | ||
{% endblock %} |
69 changes: 69 additions & 0 deletions
69
src/patterns/language-selection/examples/many-languages/ga.njk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
layout: none | ||
--- | ||
{% extends "styles/page-template/_template.njk" %} | ||
|
||
{% set page = { | ||
"title": "Enw'r gwasanaeth", | ||
"language": { | ||
"languages": [ | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages", | ||
"ISOCode": "en-GB", | ||
"text": "English", | ||
"buttonAriaLabel": "Language selector. Current language: English", | ||
"chooseLanguage": "Choose language", | ||
"current": false | ||
}, | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages/cy.html", | ||
"ISOCode": "cy", | ||
"text": "Cymraeg", | ||
"buttonAriaLabel": "Dewisydd iaith. Iaith gyfredol: Cymraeg", | ||
"chooseLanguage": "Dewiswch iaith", | ||
"current": false | ||
}, | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages/ga.html", | ||
"ISOCode": "ga", | ||
"text": "Gaeilge", | ||
"buttonAriaLabel": "Roghnóir teanga. Teanga reatha: Gaeilge", | ||
"chooseLanguage": "Roghnaigh teanga", | ||
"current": true | ||
}, | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages/sco.html", | ||
"ISOCode": "sco", | ||
"text": "Ulstèr-Scotch", | ||
"buttonAriaLabel": "Leid selectgor. Current leid: Ulstèr-Scotch", | ||
"chooseLanguage": "Wale leid", | ||
"current": false | ||
} | ||
] | ||
}, | ||
"footer": { | ||
"rows": [ | ||
{ | ||
"items": [ | ||
{ | ||
"text": "Glaoigh orainn", | ||
"url": "#" | ||
}, | ||
{ | ||
"text": "Fianáin agus príobháideachas", | ||
"url": "#" | ||
} | ||
] | ||
} | ||
], | ||
"OGLLink": { | ||
"pre": "Tá an t-ábhar go léir ar fáil faoin", | ||
"link": "gCeadúnas Oscailte Rialtais v3.0", | ||
"url": "https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/", | ||
"post": ", ach amháin nuair a luaitear a mhalairt" | ||
} | ||
} | ||
} %} | ||
|
||
{% block content %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/patterns/language-selection/examples/many-languages/sco.njk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
layout: none | ||
--- | ||
{% extends "styles/page-template/_template.njk" %} | ||
|
||
{% set page = { | ||
"title": "Ainm na seirbhíse", | ||
"language": { | ||
"languages": [ | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages", | ||
"ISOCode": "en-GB", | ||
"text": "English", | ||
"buttonAriaLabel": "Language selector. Current language: English", | ||
"chooseLanguage": "Choose language", | ||
"current": false | ||
}, | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages/cy.html", | ||
"ISOCode": "cy", | ||
"text": "Cymraeg", | ||
"buttonAriaLabel": "Dewisydd iaith. Iaith gyfredol: Cymraeg", | ||
"chooseLanguage": "Dewiswch iaith", | ||
"current": false | ||
}, | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages/ga.html", | ||
"ISOCode": "ga", | ||
"text": "Gaeilge", | ||
"buttonAriaLabel": "Roghnóir teanga. Teanga reatha: Gaeilge", | ||
"chooseLanguage": "Roghnaigh teanga", | ||
"current": false | ||
}, | ||
{ | ||
"url": "/patterns/language-selection/examples/many-languages/sco.html", | ||
"ISOCode": "sco", | ||
"text": "Ulstèr-Scotch", | ||
"buttonAriaLabel": "Leid selectgor. Current leid: Ulstèr-Scotch", | ||
"chooseLanguage": "Wale leid", | ||
"current": true | ||
} | ||
] | ||
}, | ||
"footer": { | ||
"rows": [ | ||
{ | ||
"items": [ | ||
{ | ||
"text": "Cuir fios thugainn", | ||
"url": "#" | ||
}, | ||
{ | ||
"text": "Briosgaidean is prìobhaideachd", | ||
"url": "#" | ||
} | ||
] | ||
} | ||
], | ||
"OGLLink": { | ||
"pre": "Tha an t-susbaint gu lèir ri fhaighinn fo", | ||
"link": "cheadachas an Riaghaltais Fhosgailte v3.0", | ||
"url": "https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/", | ||
"post": ", ach a-mhàin far a bheil a chaochladh air a ràdh" | ||
} | ||
} | ||
} %} | ||
|
||
{% block content %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters