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

Fix invalid aria role v4 #1250

Merged
merged 3 commits into from
Jun 18, 2024
Merged
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
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
Loading