Skip to content

Commit

Permalink
Fix invalid aria role v4 (#1250)
Browse files Browse the repository at this point in the history
* fix invalid ARIA role attribute on v4

* change 'itemClick' test to match the new role change

* Store the result of this.getItemAriaRole() in a constant
  • Loading branch information
Galpittel committed Jun 18, 2024
1 parent b3cecde commit c94002e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/gallery/src/components/item/itemView.js
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,7 @@ class ItemView extends React.Component {
const isItemWrapperEmpty =
options.titlePlacement !== GALLERY_CONSTS.placements.SHOW_ON_HOVER &&
!this.hasRequiredMediaUrl;
const itemAriaRole = this.getItemAriaRole();
const innerDiv = (
<div
className={this.getItemContainerClass()}
Expand All @@ -999,7 +1000,7 @@ class ItemView extends React.Component {
data-hash={hash}
data-id={photoId}
data-idx={idx}
role={this.getItemAriaRole()}
{...(itemAriaRole && { role: itemAriaRole })}
data-hook="item-container"
key={'item-container-' + id}
style={this.getItemContainerStyles()}
Expand Down
4 changes: 2 additions & 2 deletions packages/gallery/tests/styleParams/itemClick.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ describe('options - itemClick', () => {
expect(item.props().role).to.eq('button');
driver.detach.proGallery();
});
it('expect "role" to be "" when "itemClick" is "nothing"', async () => {
it('expect no "role" attribute when "itemClick" is "nothing"', async () => {
initialProps.options = mergeNestedObjects(initialProps.options, {
itemClick: 'nothing',
});
driver.mount.proGallery(initialProps);
await driver.update();
const item = driver.find.hook('item-container').at(3);
expect(item.props().role).to.eq('');
expect(item.props()).to.not.have.property('role');
driver.detach.proGallery();
});
});
Expand Down

0 comments on commit c94002e

Please sign in to comment.