Skip to content

Commit

Permalink
Treeview and List: Add localization for item checkBoxes aria-label va…
Browse files Browse the repository at this point in the history
…lue 'Check State' (T1247518) (#28098)
  • Loading branch information
nikkithelegendarypokemonster authored Sep 25, 2024
1 parent 4517867 commit 663a1e6
Show file tree
Hide file tree
Showing 33 changed files with 73 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { extend } from '@js/core/utils/extend';
import { name as clickEventName } from '@js/events/click';
import eventsEngine from '@js/events/core/events_engine';
import { addNamespace } from '@js/events/utils/index';
import messageLocalization from '@js/localization/message';
import CheckBox from '@js/ui/check_box';
import RadioButton from '@js/ui/radio_group/radio_button';
import errors from '@js/ui/widget/ui.errors';
Expand Down Expand Up @@ -55,7 +56,7 @@ registerDecorator(
// eslint-disable-next-line no-new
new this._controlWidget($control, extend(this._commonOptions(), {
value: this._isSelected($itemElement),
elementAttr: { 'aria-label': 'Check State' },
elementAttr: { 'aria-label': messageLocalization.format('CheckState') },
focusStateEnabled: false,
hoverStateEnabled: false,
onValueChanged: function (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ const TreeViewBase = (HierarchicalCollectionWidget as any).inherit({
value: node.internalFields.selected,
onValueChanged: this._changeCheckboxValue.bind(this),
focusStateEnabled: false,
elementAttr: { 'aria-label': 'Check State' },
elementAttr: { 'aria-label': messageLocalization.format('CheckState') },
disabled: this._disabledGetter(node),
});
},
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "نعم",
"No": "لا",
"Cancel": "الغاء",
"CheckState": "Check state",
"Close": "إغلاق",
"Clear": "تنضيف",
"Done": "تم",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "",
"No": "No",
"Cancel": "Cancel·lar",
"CheckState": "Check state",
"Close": "Tanca",
"Clear": "Clar",
"Done": "Fer",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Ano",
"No": "Ne",
"Cancel": "Zrušit",
"CheckState": "Check state",
"Close": "Zavřít",
"Clear": "Smazat",
"Done": "Hotovo",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Ja",
"No": "Nein",
"Cancel": "Abbrechen",
"CheckState": "Check state",
"Close": "Schließen",
"Clear": "Löschen",
"Done": "Fertig",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Ναί",
"No": "Όχι",
"Cancel": "Ακύρωση",
"CheckState": "Check state",
"Close": "Κλείσιμο",
"Clear": "Εκκαθάριση",
"Done": "Καταχώρηση",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Yes",
"No": "No",
"Cancel": "Cancel",
"CheckState": "Check state",
"Close": "Close",
"Clear": "Clear",
"Done": "Done",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "",
"No": "No",
"Cancel": "Cancelar",
"CheckState": "Check state",
"Close": "Cerca",
"Clear": "Limpiar",
"Done": "Hecho",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "بلی",
"No": "خیر",
"Cancel": "لغو",
"CheckState": "Check state",
"Close": "Close",
"Clear": "حذف",
"Done": "تایید",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Kyllä",
"No": "Ei",
"Cancel": "Peruuta",
"CheckState": "Check state",
"Close": "Sulkea",
"Clear": "Tyhjennä",
"Done": "Valmis",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Oui",
"No": "Non",
"Cancel": "Annuler",
"CheckState": "Check state",
"Close": "Fermer",
"Clear": "Vider",
"Done": "Terminé",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Igen",
"No": "Nem",
"Cancel": "Mégse",
"CheckState": "Check state",
"Close": "Bezárás",
"Clear": "Törlés",
"Done": "Kész",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "",
"No": "No",
"Cancel": "Annulla",
"CheckState": "Check state",
"Close": "Chiudi",
"Clear": "Cancella",
"Done": "Fatto",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "はい",
"No": "いいえ",
"Cancel": "キャンセル",
"CheckState": "Check state",
"Close": "閉じる",
"Clear": "クリア",
"Done": "完了",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Taip",
"No": "Ne",
"Cancel": "Atšaukti",
"CheckState": "Check state",
"Close": "Close",
"Clear": "Išvalyti",
"Done": "Atlikta",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/lv.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "",
"No": "",
"Cancel": "Atcelt",
"CheckState": "Check state",
"Close": "Aizvērt",
"Clear": "Notīrīt",
"Done": "Gatavs",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Ja",
"No": "Nei",
"Cancel": "Avbryt",
"CheckState": "Check state",
"Close": "Lukke",
"Clear": "Slett",
"Done": "Fullført",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Ja",
"No": "Nee",
"Cancel": "Annuleren",
"CheckState": "Check state",
"Close": "Sluiten",
"Clear": "Wissen",
"Done": "Klaar",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Tak",
"No": "Nie",
"Cancel": "Anuluj",
"CheckState": "Check state",
"Close": "Zamknij",
"Clear": "Usuń",
"Done": "Gotowe",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Sim",
"No": "Não",
"Cancel": "Cancelar",
"CheckState": "Check state",
"Close": "Fechar",
"Clear": "Limpar",
"Done": "Concluído",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Da",
"No": "Nu",
"Cancel": "Anulare",
"CheckState": "Check state",
"Close": "Închide",
"Clear": "Curăță",
"Done": "Gata",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Да",
"No": "Нет",
"Cancel": "Отмена",
"CheckState": "Check state",
"Close": "Закрыть",
"Clear": "Очистить",
"Done": "Готово",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Da",
"No": "Ne",
"Cancel": "Prekliči",
"CheckState": "Check state",
"Close": "Zapri",
"Clear": "Pobriši",
"Done": "Končano",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Ja",
"No": "Nej",
"Cancel": "Avbryt",
"CheckState": "Check state",
"Close": "Stäng",
"Clear": "Rensa",
"Done": "Klar",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "Evet",
"No": "Hayır",
"Cancel": "İptal",
"CheckState": "Check state",
"Close": "Kapat",
"Clear": "Temizle",
"Done": "Tamam",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "",
"No": "Không",
"Cancel": "Hủy",
"CheckState": "Check state",
"Close": "Đóng",
"Clear": "Làm sạch",
"Done": "Hoàn tất",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "",
"No": "",
"Cancel": "取消",
"CheckState": "Check state",
"Close": "關閉",
"Clear": "清除",
"Done": "完成",
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/js/localization/messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"Yes": "",
"No": "",
"Cancel": "取消",
"CheckState": "Check state",
"Close": "關閉",
"Clear": "清除",
"Done": "完成",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ariaAccessibilityTestHelper {
const expectedAttributes = {
role: 'checkbox',
'aria-checked': $checkBox.hasClass('dx-checkbox-indeterminate') ? 'mixed' : defaultValue,
'aria-label': 'Check State',
'aria-label': 'Check state',
};

if(attributes && attributes.includes('aria-disabled')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { isRenderer } from 'core/utils/type';
import config from 'core/config';
import devices from 'core/devices';
import List from 'ui/list';
import localization from 'localization';
import ariaAccessibilityTestHelper from '../../helpers/ariaAccessibilityTestHelper.js';

import 'generic_light.css!';
Expand Down Expand Up @@ -432,6 +433,8 @@ const TOGGLE_DELETE_SWITCH_CLASS = 'dx-list-toggle-delete-switch';
const TOGGLE_DELETE_SWITCH_ICON_CLASS = 'dx-icon-toggle-delete';
const SELECT_CHECKBOX_CONTAINER_CLASS = 'dx-list-select-checkbox-container';
const SELECT_CHECKBOX_CLASS = 'dx-list-select-checkbox';
const SELECT_ALL_CHECKBOX_CLASS = 'dx-list-select-all-checkbox';
const SELECT_ALL_CLASS = 'dx-list-select-all';
const SELECT_RADIO_BUTTON_CONTAINER_CLASS = 'dx-list-select-radiobutton-container';
const SELECT_RADIO_BUTTON_CLASS = 'dx-list-select-radiobutton';
const REORDER_HANDLE_CONTAINER_CLASS = 'dx-list-reorder-handle-container';
Expand Down Expand Up @@ -531,6 +534,24 @@ QUnit.module('decorators markup', {}, () => {
assert.equal($checkbox.length, 1, 'checkbox rendered');
});

QUnit.test('item checkbox aria-label attribute should be equal to custom localized text (T1247518)', function(assert) {
const localizedCheckStateText = 'custom-select-all';
localization.loadMessages({ 'en': { 'CheckState': localizedCheckStateText } });

const $list = $($('#list').dxList({
dataSource: [
{ id: 1, text: 'Item 1' },
{ id: 2, text: 'Item 2' },
{ id: 3, text: 'Item 3' },
],
showSelectionControls: true,
selectionMode: 'all',
}));
const $itemCheckBox = $list.find(`.${SELECT_CHECKBOX_CLASS}`).eq(0);

assert.strictEqual($itemCheckBox.attr('aria-label'), localizedCheckStateText, 'item checkbox aria-label is equal to localized text');
});

QUnit.test('list item markup should be correct, reordering decorator', function(assert) {
const $list = $($('#templated-list').dxList({
items: ['0'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4184,7 +4184,7 @@ QUnit.test('SelectAll checkbox should have aria-label="Select All" attribute', f
assert.strictEqual($selectAllCheckBox.attr('aria-label'), 'Select All');
});

QUnit.test('checkbox should have aria-label="Check State" attribute', function(assert) {
QUnit.test('checkbox should have aria-label="Check state" attribute', function(assert) {
$('#list').dxList({
items: ['text 1', 'text 2'],
selectionMode: 'multiple',
Expand All @@ -4193,10 +4193,10 @@ QUnit.test('checkbox should have aria-label="Check State" attribute', function(a

const $checkboxes = $(`.${LIST_SELECT_CHECKBOX_CLASS}`);

assert.strictEqual($checkboxes.attr('aria-label'), 'Check State');
assert.strictEqual($checkboxes.attr('aria-label'), 'Check state');
});

QUnit.test('radio buttons should have aria-label="Check State" attribute', function(assert) {
QUnit.test('radio buttons should have aria-label="Check state" attribute', function(assert) {
$('#list').dxList({
items: ['text 1', 'text 2'],
selectionMode: 'single',
Expand All @@ -4205,7 +4205,7 @@ QUnit.test('radio buttons should have aria-label="Check State" attribute', funct

const $radioButtons = $(`.${LIST_SELECT_RADIOBUTTON_CLASS}`);

assert.strictEqual($radioButtons.attr('aria-label'), 'Check State');
assert.strictEqual($radioButtons.attr('aria-label'), 'Check state');
});

let helper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import TreeViewTestWrapper from '../../helpers/TreeViewTestHelper.js';
import { Deferred } from 'core/utils/deferred';
import CustomStore from 'data/custom_store';
import { DATA, data2 } from './treeViewParts/testData.js';
import localization from 'localization';
import 'ui/tree_view';

import 'generic_light.css!';
Expand Down Expand Up @@ -307,15 +308,29 @@ QUnit.test('selectAll checkbox should have aria-label="Select All" attribute', f
assert.strictEqual($selectAllCheckbox.attr('aria-label'), 'Select All');
});

QUnit.test('checkbox should have aria-label="Check State" attribute', function(assert) {
QUnit.test('checkbox should have aria-label="Check state" attribute', function(assert) {
initTree({
items: [ { text: 'item' } ],
showCheckBoxesMode: 'normal'
});

const $checkbox = $(`.${CHECKBOX_CLASS}`);

assert.strictEqual($checkbox.attr('aria-label'), 'Check State');
assert.strictEqual($checkbox.attr('aria-label'), 'Check state');
});

QUnit.test('checkbox should have a correct aria-label value based on localization (T1247518)', function(assert) {
const localizedCheckStateText = 'custom-select-all';
localization.loadMessages({ 'en': { 'CheckState': localizedCheckStateText } });

initTree({
items: [ { text: 'item' } ],
showCheckBoxesMode: 'normal'
});

const $checkbox = $(`.${CHECKBOX_CLASS}`);

assert.strictEqual($checkbox.attr('aria-label'), localizedCheckStateText, 'checkbox aria-label has correct localized value');
});

QUnit.test('SelectAll checkBox should select all values on enter key when no items selected', function(assert) {
Expand Down

0 comments on commit 663a1e6

Please sign in to comment.