Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 8 additions & 1 deletion packages/devextreme/js/__internal/ui/list/list.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,14 @@ export class ListBase extends CollectionWidget<ListBaseProperties, Item> {
};

this.setAria(elementAria, this.$element());
this.setAria({ role: 'application' }, this._focusTarget());

const { items } = this.option();

if (items?.length) {
this.setAria({ role: 'application' }, this._focusTarget());
} else {
this._focusTarget().removeAttr('role');
}

this._setListAria();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3734,7 +3734,6 @@ if(devices.real().deviceType === 'desktop') {

const listItemContainerAttributes = {
tabindex: searchEnabled ? '-1' : '0',
role: 'application',
};

let fieldAttributes = {
Expand Down Expand Up @@ -3891,15 +3890,15 @@ if(devices.real().deviceType === 'desktop') {
const $scrollView = $list.find(`.${SCROLL_VIEW_CONTENT_CLASS}`);
const $itemsContainer = $list.find(`.${LIST_ITEMS_CLASS}`);

helper.checkAttributes($scrollView, { tabindex: '-1', role: 'application' });
helper.checkAttributes($scrollView, { tabindex: '-1' });
helper.checkAttributes($itemsContainer, { });

helper.widget.option(dataSourcePropertyName, [1, 2, 3]);
helper.checkAttributes($scrollView, { tabindex: '-1', role: 'application' });
helper.checkAttributes($itemsContainer, { 'aria-label': 'Items', role: 'listbox' });

helper.widget.option(dataSourcePropertyName, []);
helper.checkAttributes($scrollView, { tabindex: '-1', role: 'application' });
helper.checkAttributes($scrollView, { tabindex: '-1' });
helper.checkAttributes($itemsContainer, { });
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6150,7 +6150,7 @@ if(devices.real().deviceType === 'desktop') {
helper.checkAttributes(helper.widget._list.$element(), listAttributes, localizedRoleDescription);

const $listItemContainer = helper.widget._list.$element().find(`.${SCROLLVIEW_CONTENT_CLASS}`);
helper.checkAttributes($listItemContainer, { role: 'application' }, 'scrollview content');
helper.checkAttributes($listItemContainer, { }, 'scrollview content');

const inputAttributes = {
autocomplete: 'off',
Expand Down Expand Up @@ -6183,7 +6183,7 @@ if(devices.real().deviceType === 'desktop') {

listAttributes.id = helper.widget._listId;
helper.checkAttributes(helper.widget._list.$element(), listAttributes, 'list');
helper.checkAttributes($listItemContainer, { role: 'application' }, 'scrollview content');
helper.checkAttributes($listItemContainer, { }, 'scrollview content');

inputAttributes['aria-controls'] = helper.widget._listId;
inputAttributes['aria-owns'] = helper.widget._popupContentId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5342,4 +5342,45 @@ QUnit.module('Accessibility', () => {
'checkbox aria-label updated after runtime change');
});

QUnit.module('Empty list cannot have role on scrollview content (T1329047)', () => {
const POPULATED_ITEMS = ['Item 1'];

const createList = (options) => $('#list').dxList(options).dxList('instance');

const getScrollViewContent = (instance) =>
instance.$element().find(`.${SCROLLVIEW_CONTENT_CLASS}`).get(0);

const getScrollViewContentRole = (instance) =>
getScrollViewContent(instance).getAttribute('role');

QUnit.test('scrollview-content should not have role when list is empty on init', function(assert) {
const instance = createList({ items: [] });

assert.strictEqual(getScrollViewContentRole(instance), null);
});

QUnit.test('scrollview-content should have role="application" when list has items', function(assert) {
const instance = createList({ items: POPULATED_ITEMS });

assert.strictEqual(getScrollViewContentRole(instance), 'application');
});

QUnit.test('scrollview-content role should be removed when items change from populated to empty', function(assert) {
const instance = createList({ items: POPULATED_ITEMS });

instance.option('items', []);

assert.strictEqual(getScrollViewContentRole(instance), null);
});

QUnit.test('scrollview-content role should be restored when items change from empty to populated', function(assert) {
const instance = createList({ items: [] });

instance.option('items', POPULATED_ITEMS);

assert.strictEqual(getScrollViewContentRole(instance), 'application');
});
});


});
Loading