Skip to content

Commit

Permalink
Page feedback tool: Polish AJAX fragments (FR pageData, role="status")
Browse files Browse the repository at this point in the history
The AJAX fragments had two minor flaws:
* The English fragment contained pageData references that were missing from the French variant. That difference caused a hidden input named "contact" (with a JSON string as its value) to be injected into French feedback widgets. Although it didn't cause any other issues (data-feedback-link and data-feedback-url still worked fine in practice).
* The no button's invisible transition message in JS mode is technically a status message, but wasn't coded as such (was using aria-live="polite" as opposed to role="status").

This resolves the flaws by:
* Adding pageData references throughout the French fragment (same spots as English) to eliminate the hidden "contact" input.
* Replacing aria-live="polite" with role="status" in the no button's transition message:
  * role="status" is a more formal way of denoting status messages, implicitly sets aria-live="polite" + aria-atomic="true" and is already in use for the widget's thank you message.
  • Loading branch information
EricDunsworth committed Jul 19, 2024
1 parent 10fb183 commit 4d05427
Show file tree
Hide file tree
Showing 6 changed files with 330 additions and 44 deletions.
93 changes: 76 additions & 17 deletions _data/sites.json
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@
}
,{
"@context": {
"@version": 2.0,
"@version": 2.1,
"dct": "http://purl.org/dc/terms/",
"title": { "@id": "dct:title", "@container": "@language" },
"description": { "@id": "dct:description", "@container": "@language" },
Expand All @@ -645,10 +645,10 @@
"en": "Documentation on how to use the elements of the feedback area.",
"fr": "Documentation sur l'utilisation des éléments de la zone commentaires."
},
"modified": "2023-01-10",
"modified": "2024-07-19",
"componentName": "feedback",
"status": "stable",
"version": "2.0",
"version": "2.1",
"pages": {
"docs": [
{
Expand Down Expand Up @@ -741,7 +741,7 @@
"en": "https://design.canada.ca/feedback/index.html",
"fr": "https://conception.canada.ca/retroaction/index.html"
},
"iteration": "_:iteration_pft_1",
"iteration": "_:iteration_pft_2",
"example": [
{
"en": { "href": "page-feedback-en.html", "text": "Page feedback tool" },
Expand All @@ -755,6 +755,10 @@
"_:implement_pft_mws_author"
],
"history": [
{
"en": "July 2024 - AJAX fragment: Added <code>pageData</code> to the French variant, changed <code>aria-live=\"polite\"</code> to <code>role=\"status\"</code> in \"Tell us why below:\".",
"fr": "Juillet 2024 - Fragment AJAX&nbsp;: Ajout de <code>pageData</code> à la variante française, changement de <code>aria-live=\"polite\"</code> à <code>role=\"status\"</code> dans «&nbsp;Dites nous pourquoi ci-dessous&nbsp;:&nbsp;»."
},
{
"en": "August 2023 - Initial implementation of the variation.",
"fr": "Août 2023 - Implémentation initiale de la variante."
Expand All @@ -775,7 +779,7 @@
"en": "https://design.canada.ca/feedback/index.html",
"fr": "https://conception.canada.ca/retroaction/index.html"
},
"iteration": "_:iteration_pft_1",
"iteration": "_:iteration_pft_2",
"example": [
{
"en": { "href": "page-feedback-contact-en.html", "text": "Page feedback tool with contact link" },
Expand Down Expand Up @@ -985,7 +989,7 @@
},
{
"@id": "_:implement_pft",
"iteration": "_:iteration_pft_1",
"iteration": "_:iteration_pft_2",
"name": {
"en": "Standard (wet-boew)",
"fr": "Standard (wet-boew)"
Expand Down Expand Up @@ -1055,7 +1059,7 @@
},
{
"@id": "_:implement_pft_gcweb",
"iteration": "_:iteration_pft_1",
"iteration": "_:iteration_pft_2",
"name": {
"en": "GCWeb Jekyll",
"fr": "GCWeb Jekyll"
Expand Down Expand Up @@ -1093,7 +1097,7 @@
},
{
"@id": "_:implement_pft_upgrade_rap",
"iteration": "_:iteration_pft_1",
"iteration": "_:iteration_pft_2",
"name": {
"en": "Upgrade from RAP",
"fr": "Mise à jour à partir de SUP"
Expand All @@ -1115,7 +1119,7 @@
},
{
"@id": "_:implement_pft_mws_author",
"iteration": "_:iteration_pft_1",
"iteration": "_:iteration_pft_2",
"name": {
"en": "MWS users",
"fr": "Utilisateur SWG"
Expand All @@ -1141,7 +1145,7 @@
},
{
"@id": "_:implement_pft_contact",
"iteration": "_:iteration_pft_1",
"iteration": "_:iteration_pft_2",
"name": {
"en": "Standard (WET-BOEW)",
"fr": "Standard (WET-BOEW)"
Expand Down Expand Up @@ -1211,7 +1215,7 @@
},
{
"@id": "_:implement_pft_contact_gcweb",
"iteration": "_:iteration_pft_1",
"iteration": "_:iteration_pft_2",
"name": {
"en": "GCWeb Jekyll",
"fr": "GCWeb Jekyll"
Expand Down Expand Up @@ -1255,7 +1259,7 @@
"@id": "_:cs_pft_container",
"name": "Page feedback tool with AJAX",
"status": "stable",
"baseOnIteration": "_:iteration_pft_1",
"baseOnIteration": "_:iteration_pft_2",
"detectableBy": ".pagedetails .wb-disable-allow[data-ajax-replace*=feedback]",
"layout": [
"At the top-left column in the page details component",
Expand Down Expand Up @@ -1303,7 +1307,7 @@
"@id": "_:cs_pft_ajax",
"name": "Page feedback tool AJAX file",
"status": "stable",
"baseOnIteration": "_:iteration_pft_1",
"baseOnIteration": "_:iteration_pft_2",
"dependOnChangeSet": "_:cs_pft_container",
"detectableBy": "<div class=\"gc-pft\">",
"layout": [
Expand Down Expand Up @@ -1600,10 +1604,15 @@
],
"iteration": [
{
"@id": "_:iteration_pft_1",
"name": "Page feedback tool - Iteration 1",
"date": "2023-08",
"detectableBy": ".gc-pft",
"@id": "_:iteration_pft_2",
"name": "Page feedback tool - Iteration 1.1",
"date": "2024-07",
"detectableBy": "#gc-pft:has(.gc-pft-no p[role=\"status\"]:nth-of-type(2))",
"fixes": [
"AJAX fragment: Added <code>pageData</code> to the French variant",
"AJAX fragment: Changed <code>aria-live=\"polite\"</code> to <code>role=\"status\"</code> in \"Tell us why below:\"."
],
"predecessor": "_:iteration_pft_1",
"assets": [
{
"@type": "source-code",
Expand Down Expand Up @@ -1649,6 +1658,56 @@
}
]
},
{
"@id": "_:iteration_pft_1",
"name": "Page feedback tool - Iteration 1",
"date": "2023-08",
"detectableBy": "#gc-pft",
"assets": [
{
"@type": "source-code",
"@language": "en",
"description": "Code sample",
"code": "<div class=\"wb-disable-allow\" \ndata-ajax-replace=\"assets/deprecated/page-feedback-v1-en.html\" \ndata-feedback-section=\"[Text defining the theme of your page]\" \ndata-feedback-theme=\"[Text defining the section where your page resides]\"></div>"
},
{
"@type": "source-code",
"@language": "en",
"description": "Code sample with contact link",
"code": "<div class=\"wb-disable-allow\" \ndata-ajax-replace=\"assets/deprecated/page-feedback-v1-en.html\" \ndata-feedback-section=\"[Text defining the theme of your page]\" \ndata-feedback-theme=\"[Text defining the section where your page resides]\"\ndata-feedback-link=\"[Contact link text]\"\ndata-feedback-url=\"[Contact link URL]\"></div>"
},
{
"@type": "source-code",
"@language": "en",
"description": "Ajaxed-in content",
"code": {
"@type": [ "rdf:HTML", "@id" ],
"@value": "assets/deprecated/page-feedback-v1-en.html"
}
},
{
"@type": "source-code",
"@language": "fr",
"description": "Exemple de code",
"code": "<div class=\"wb-disable-allow\" \ndata-ajax-replace=\"assets/page-feedback-fr.html\" \ndata-feedback-section=\"[Texte définissant le thème de votre page]\" \ndata-feedback-theme=\"[Texte définissant la section où réside votre page]\"\ndata-feedback-link=\"[Texte du lien de contact]\"\ndata-feedback-url=\"[URL du lien de contact]\"></div>"
},
{
"@type": "source-code",
"@language": "fr",
"description": "Exemple de code avec lien de contact",
"code": "<div class=\"wb-disable-allow\" \ndata-ajax-replace=\"assets/page-feedback-fr.html\" \ndata-feedback-section=\"[Texte définissant le thème de votre page]\" \ndata-feedback-theme=\"[Texte définissant la section où réside votre page]\"></div>"
},
{
"@type": "source-code",
"@language": "fr",
"description": "Contenu ajouté via Ajax",
"code": {
"@type": [ "rdf:HTML", "@id" ],
"@value": "assets/deprecated/page-feedback-v1-fr.html"
}
}
]
},
{
"@id": "_:iteration_rap_5",
"name": "Report a problem - Iteration 5",
Expand Down
84 changes: 84 additions & 0 deletions sites/feedback/assets/deprecated/page-feedback-v1-en.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<div id="gc-pft" class="row wb-disable-allow" data-wb-jsonmanager='{
"name": "gc-pft",
"extractor": [
{ "selector": "title", "path": "pageData/pageTitle" },
{ "selector": "html", "attr": "lang", "path": "pageData/language" },
{ "interface": "locationHref", "path": "pageData/submissionPage" },
{ "selector": "#wb-lng ul li:first-child a[lang]", "attr": "href", "path": "pageData/oppositelang" },
{ "selector": "[data-feedback-theme]", "attr": "data-feedback-theme", "path": "pageData/themeopt" },
{ "selector": "[data-feedback-section]", "attr": "data-feedback-section", "path": "pageData/sectionopt" },
{ "selector": "meta[name=\"dcterms.creator\"]", "attr": "content", "path": "pageData/institutionopt" },
{ "selector": "[data-feedback-link]", "attr": "data-feedback-link", "path": "contact/link" },
{ "selector": "[data-feedback-url]", "attr": "data-feedback-url", "path": "contact/url" }
]
}'>
<div class="col-sm-10 col-md-9 col-lg-8">
<section class="well mrgn-bttm-0">
<h3 class="wb-inv">Give feedback about this page</h3>
<form action="https://feedback-retroaction.canada.ca/api/QueueProblemForm" method="post" class="wb-postback wb-disable-allow" data-wb-postback='{"success":".gc-pft-thnk"}'>
<div class="wb-disable-allow" data-wb-json='{
"url": "#[gc-pft]/pageData",
"mapping": [
{ "selector": "input", "attr": "name", "value": "/@id" },
{ "selector": "input", "attr": "value", "value": "/@value" }
]
}'>
<template>
<input type="hidden" name="" value="" />
</template>
</div>
<fieldset class="gc-pft-btns chkbxrdio-grp row row-no-gutters d-sm-flex flex-sm-wrap align-items-sm-center">
<legend class="col-xs-12 col-sm-7 nojs-col-sm-12 col-md-9 col-lg-8 text-center text-sm-left nojs-text-left mrgn-tp-sm pr-sm-3"><span class="field-name">Did you find what you were looking for?</span></legend>
<div class="col-xs-12 nojs-show">
<button name="helpful" value="Yes-Oui" class="btn btn-primary" aria-describedby="gc-pft-why">Yes</button>
</div>
<div class="col-xs-12 col-sm-5 col-md-3 col-lg-4 text-center text-sm-right nojs-hide">
<button name="helpful" value="Yes-Oui" class="btn btn-primary">Yes</button>
<button class="btn btn-primary mrgn-lft-sm" data-wb-doaction='[
{"action":"removeClass","source":".gc-pft-no","class":"nojs-show"},
{"action":"addClass","source":".gc-pft-btns","class":"hide"}
]'>No</button>
</div>
</fieldset>
<div class="gc-pft-no nojs-show">
<p id="gc-pft-why" class="nojs-show mrgn-tp-lg mrgn-bttm-md">If not, tell us why below:</p>
<p class="nojs-hide wb-inv" aria-live="polite">Tell us why below:</p>
<div class="wb-disable-allow" data-wb-json='{
"url": "#[gc-pft]/contact",
"streamline": "true",
"mapping": [
{
"template": "[data-contact-template]",
"test": "fn:isLiteral",
"assess": "/url",
"mapping": [
{ "selector": "a", "type": "attr", "attr": "href", "value": "/url" },
{ "selector": "a", "value": "/link" }
]
}
]
}'>
<template data-contact-template>
<details>
<summary>Need urgent help with a problem? Contact us</summary>
<p class="mrgn-bttm-0 mrgn-tp-md fnt-nrml">
<a href="#"></a>
</p>
</details>
</template>
</div>
<div class="form-group">
<label id="gc-pft-prblm-label" for="gc-pft-prblm" class="mrgn-bttm-0"><span class="field-name">Please provide more details</span></label>
<p id="gc-pft-prblm-note" class="mrgn-bttm-sm"><small>You will not receive a reply. Don't include personal information (telephone, email, SIN, financial, medical, or work details).</small></p>
<p id="gc-pft-prblm-instruction" class="fnt-nrml small">Maximum 300 characters</p>
<textarea id="gc-pft-prblm" aria-describedby="gc-pft-prblm-note gc-pft-prblm-instruction" name="details" class="form-control full-width" maxlength="300"></textarea>
</div>
<button name="helpful" value="No-Non" class="btn btn-primary">Submit</button>
</div>
</form>
<div class="gc-pft-thnk hide">
<p class="mrgn-tp-sm mrgn-bttm-0" role="status"><span class="glyphicon glyphicon-ok text-success mrgn-rght-sm" aria-hidden="true"></span> Thank you for your feedback.</p>
</div>
</section>
</div>
</div>
84 changes: 84 additions & 0 deletions sites/feedback/assets/deprecated/page-feedback-v1-fr.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<div id="gc-pft" class="row wb-disable-allow" data-wb-jsonmanager='{
"name": "gc-pft",
"extractor": [
{ "selector": "title", "path": "pageTitle" },
{ "selector": "html", "attr": "lang", "path": "language" },
{ "interface": "locationHref", "path": "submissionPage" },
{ "selector": "#wb-lng ul li:first-child a[lang]", "attr": "href", "path": "oppositelang" },
{ "selector": "[data-feedback-theme]", "attr": "data-feedback-theme", "path": "themeopt" },
{ "selector": "[data-feedback-section]", "attr": "data-feedback-section", "path": "sectionopt" },
{ "selector": "meta[name=\"dcterms.creator\"]", "attr": "content", "path": "institutionopt" },
{ "selector": "[data-feedback-link]", "attr": "data-feedback-link", "path": "contact/link" },
{ "selector": "[data-feedback-url]", "attr": "data-feedback-url", "path": "contact/url" }
]
}'>
<div class="col-sm-10 col-md-9 col-lg-8">
<section class="well mrgn-bttm-0">
<h3 class="wb-inv">Donnez votre rétroaction sur cette page</h3>
<form action="https://feedback-retroaction.canada.ca/api/QueueProblemForm" method="post" class="wb-postback wb-disable-allow" data-wb-postback='{"success":".gc-pft-thnk"}'>
<div class="wb-disable-allow" data-wb-json='{
"url": "#[gc-pft]",
"mapping": [
{ "selector": "input", "attr": "name", "value": "/@id" },
{ "selector": "input", "attr": "value", "value": "/@value" }
]
}'>
<template>
<input type="hidden" name="" value="" />
</template>
</div>
<fieldset class="gc-pft-btns chkbxrdio-grp row row-no-gutters d-sm-flex flex-sm-wrap align-items-sm-center">
<legend class="col-xs-12 col-sm-7 nojs-col-sm-12 col-md-9 col-lg-8 text-center text-sm-left nojs-text-left mrgn-tp-sm pr-sm-3"><span class="field-name">Avez-vous trouvé ce que vous cherchiez?</span></legend>
<div class="col-xs-12 nojs-show">
<button name="helpful" value="Yes-Oui" class="btn btn-primary" aria-describedby="gc-pft-why">Oui</button>
</div>
<div class="col-xs-12 col-sm-5 col-md-3 col-lg-4 text-center text-sm-right nojs-hide">
<button name="helpful" value="Yes-Oui" class="btn btn-primary">Oui</button>
<button class="btn btn-primary mrgn-lft-sm" data-wb-doaction='[
{"action":"removeClass","source":".gc-pft-no","class":"nojs-show"},
{"action":"addClass","source":".gc-pft-btns","class":"hide"}
]'>Non</button>
</div>
</fieldset>
<div class="gc-pft-no nojs-show">
<p id="gc-pft-why" class="nojs-show mrgn-tp-lg mrgn-bttm-md">Sinon, dites nous pourquoi ci-dessous&nbsp;:</p>
<p class="nojs-hide wb-inv" aria-live="polite">Dites nous pourquoi ci-dessous&nbsp;:</p>
<div class="wb-disable-allow" data-wb-json='{
"url": "#[gc-pft]/contact",
"streamline": "true",
"mapping": [
{
"template": "[data-contact-template]",
"test": "fn:isLiteral",
"assess": "/url",
"mapping": [
{ "selector": "a", "type": "attr", "attr": "href", "value": "/url" },
{ "selector": "a", "value": "/link" }
]
}
]
}'>
<template data-contact-template>
<details>
<summary>Besoin d’aide urgente pour résoudre un problème? Communiquez avec nous</summary>
<p class="mrgn-bttm-0 mrgn-tp-md fnt-nrml">
<a href="#"></a>
</p>
</details>
</template>
</div>
<div class="form-group">
<label for="gc-pft-prblm" class="mrgn-bttm-0"><span class="field-name">Veuillez fournir plus de détails</span></label>
<p id="gc-pft-prblm-note" class="mrgn-bttm-sm"><small>Vous ne recevrez pas de réponse. N'incluez pas de renseignements personnels (téléphone, courriel, NAS, renseignements financiers, médicaux ou professionnels).</small></p>
<p id="gc-pft-prblm-instruction" class="fnt-nrml small">Maximum de 300 caractères</p>
<textarea id="gc-pft-prblm" aria-describedby="gc-pft-prblm-note gc-pft-prblm-instruction" name="details" class="form-control full-width" maxlength="300"></textarea>
</div>
<button name="helpful" value="No-Non" class="btn btn-primary">Soumettre</button>
</div>
</form>
<div class="gc-pft-thnk hide">
<p class="mrgn-tp-sm mrgn-bttm-0" role="status"><span class="glyphicon glyphicon-ok text-success mrgn-rght-sm" aria-hidden="true"></span> Merci de vos commentaires.</p>
</div>
</section>
</div>
</div>
2 changes: 1 addition & 1 deletion sites/feedback/assets/page-feedback-en.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h3 class="wb-inv">Give feedback about this page</h3>
</fieldset>
<div class="gc-pft-no nojs-show">
<p id="gc-pft-why" class="nojs-show mrgn-tp-lg mrgn-bttm-md">If not, tell us why below:</p>
<p class="nojs-hide wb-inv" aria-live="polite">Tell us why below:</p>
<p class="nojs-hide wb-inv" role="status">Tell us why below:</p>
<div class="wb-disable-allow" data-wb-json='{
"url": "#[gc-pft]/contact",
"streamline": "true",
Expand Down
Loading

0 comments on commit 4d05427

Please sign in to comment.