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

Gallery - fix Axe errors #25540

Merged
merged 17 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
alexanderPolosatov marked this conversation as resolved.
Show resolved Hide resolved
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Mostrar recursos",
"dxGantt-showDependencies": "Mostrar dependències",
"dxGantt-dialogStartDateValidation": "La data d'inici ha de ser després de {0}",
"dxGantt-dialogEndDateValidation": "La data de finalització ha de ser després de {0}"
"dxGantt-dialogEndDateValidation": "La data de finalització ha de ser després de {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Ressourcen Anzeigen",
"dxGantt-showDependencies": "Abhängigkeiten Anzeigen",
"dxGantt-dialogStartDateValidation": "Startdatum muss später sein als {0}",
"dxGantt-dialogEndDateValidation": "Enddatum muss später sein als {0}"
"dxGantt-dialogEndDateValidation": "Enddatum muss später sein als {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Mostrar Recursos",
"dxGantt-showDependencies": "Mostrar Dependencias",
"dxGantt-dialogStartDateValidation": "La fecha de inicio debe ser anterior {0}",
"dxGantt-dialogEndDateValidation": "La fecha de finalización debe ser posterior {0}"
"dxGantt-dialogEndDateValidation": "La fecha de finalización debe ser posterior {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Afficher les ressources",
"dxGantt-showDependencies": "Afficher les dépendances",
"dxGantt-dialogStartDateValidation": "La date de début doit être postérieure au {0}",
"dxGantt-dialogEndDateValidation": "La date de fin doit être postérieure au {0}"
"dxGantt-dialogEndDateValidation": "La date de fin doit être postérieure au {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "リソースを表示",
"dxGantt-showDependencies": "依存関係を表示",
"dxGantt-dialogStartDateValidation": "開始日を {0} 以降にする必要があります",
"dxGantt-dialogEndDateValidation": "終了日は {0} より後にする必要があります"
"dxGantt-dialogEndDateValidation": "終了日は {0} より後にする必要があります",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Rodyti resursus",
"dxGantt-showDependencies": "Rodyti priklausomybes",
"dxGantt-dialogStartDateValidation": "Pradžios data turi būti po {0}",
"dxGantt-dialogEndDateValidation": "Pabaigos data turi būti po {0}"
"dxGantt-dialogEndDateValidation": "Pabaigos data turi būti po {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/lv.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Rādīt Resursus",
"dxGantt-showDependencies": "Rādīt Sasaistes",
"dxGantt-dialogStartDateValidation": "Sākuma datumam jābūt vēlākam par {0}",
"dxGantt-dialogEndDateValidation": "Beigu datumam jābūt vēlākam par {0}"
"dxGantt-dialogEndDateValidation": "Beigu datumam jābūt vēlākam par {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/nb.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Mostrar recursos",
"dxGantt-showDependencies": "Mostrar dependências",
"dxGantt-dialogStartDateValidation": "A data de início deve ser após {0}",
"dxGantt-dialogEndDateValidation": "A data de término deve ser posterior a {0}"
"dxGantt-dialogEndDateValidation": "A data de término deve ser posterior a {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Отображать Ресурсы",
"dxGantt-showDependencies": "Отображать Зависимости",
"dxGantt-dialogStartDateValidation": "Начальная дата должна быть позднее {0}",
"dxGantt-dialogEndDateValidation": "Конечная дата должна быть позднее {0}"
"dxGantt-dialogEndDateValidation": "Конечная дата должна быть позднее {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
4 changes: 3 additions & 1 deletion packages/devextreme/js/localization/messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@
"dxGantt-showResources": "Show Resources",
"dxGantt-showDependencies": "Show Dependencies",
"dxGantt-dialogStartDateValidation": "Start date must be after {0}",
"dxGantt-dialogEndDateValidation": "End date must be after {0}"
"dxGantt-dialogEndDateValidation": "End date must be after {0}",

"dxGallery-galleryItemName": "Gallery item"
}
}
20 changes: 14 additions & 6 deletions packages/devextreme/js/ui/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Swipeable from '../events/gesture/swipeable';
import { BindableTemplate } from '../core/templates/bindable_template';
import { Deferred } from '../core/utils/deferred';
import { triggerResizeEvent } from '../events/visibility_change';
import messageLocalization from '../localization/message';

// STYLE gallery

Expand Down Expand Up @@ -146,7 +147,10 @@ const Gallery = CollectionWidget.inherit({
*/


_itemAttributes: { role: 'option' },
_itemAttributes: {
role: 'option',
'aria-label': messageLocalization.format('dxGallery-galleryItemName')
},
loopItemFocus: false,
selectOnFocus: true,
selectionMode: 'single',
Expand Down Expand Up @@ -273,10 +277,13 @@ const Gallery = CollectionWidget.inherit({

this.callBase();

this.setAria({
'role': 'listbox',
const useListBoxRole = this._itemsCount() > 0;
const ariaAttrs = {
'role': useListBoxRole ? 'listbox' : undefined,
'label': 'gallery'
});
};

this.setAria(ariaAttrs);
},

_render: function() {
Expand Down Expand Up @@ -392,10 +399,11 @@ const Gallery = CollectionWidget.inherit({
const $clonedItem = $(item)
.clone(false)
.addClass(GALLERY_LOOP_ITEM_CLASS)
.removeAttr('id')
.css('margin', 0)
.appendTo($container);

this.setAria({ role: 'presentation' }, $clonedItem);
this.setAria({ hidden: true }, $clonedItem);
}
},

Expand Down Expand Up @@ -946,7 +954,7 @@ const Gallery = CollectionWidget.inherit({
_setFocusOnSelect: function() {
this._userInteraction = true;

const selectedItem = this.itemElements().filter('.' + GALLERY_ITEM_SELECTED_CLASS);
const selectedItem = this._getRealItems().filter('.' + GALLERY_ITEM_SELECTED_CLASS);
this.option('focusedElement', getPublicElement(selectedItem));
this._userInteraction = false;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* eslint-disable no-restricted-syntax */
import url from '../../helpers/getPageUrl';
import createWidget from '../../helpers/createWidget';
import { a11yCheck } from '../../helpers/accessibilityUtils';

fixture.disablePageReloads`Gallery`
.page(url(__dirname, '../../container.html'));

interface GalleryItem {
ID: string;
Name: string;
}

const defaultItems: GalleryItem[] = [{
ID: '1',
Name: 'First',
},
{
ID: '2',
Name: 'Second',
}];

function defaultItemTemplate(item: GalleryItem) {
const result = document.createElement('div');
const span = document.createElement('span');

span.innerText = item.Name;
result.appendChild(span);

return result;
}

function getTestName(gallerySettings) {
const fields = Object.keys(gallerySettings);

const messageParts = fields.map((field) => {
const fieldSkipped = gallerySettings[field] === undefined;

return `${field} was ${fieldSkipped ? 'not' : ''} set`;
});

return `Checking Gallery via aXe. Settings: ${messageParts.join(', ')}`;
}

const gallerySettings = [{}, {
items: defaultItems,
}, {
itemTemplate: defaultItemTemplate,
}, {
width: '100%',
}, {
loop: true,
}, {
showIndicator: false,
}].reduce((acc: any, currentValue, index, arr) => {
acc.push({
...currentValue,
...arr[index - 1],
});
return acc;
}, []);
ksercs marked this conversation as resolved.
Show resolved Hide resolved

const testsSettings: {
testName: string;
gallerySettings: any;
}[] = gallerySettings.map((settings) => ({
testName: getTestName(settings),
gallerySettings: settings,
}));

testsSettings.forEach((settings) => {
alexanderPolosatov marked this conversation as resolved.
Show resolved Hide resolved
test(settings.testName, async (t) => {
await a11yCheck(t);
}).before(async () => createWidget(
'dxGallery',
settings.gallerySettings,
));
});
Loading
Loading