From 7d603b7da41736f2b64f91493796d4fe8ebda17a Mon Sep 17 00:00:00 2001 From: Galpittel Date: Mon, 17 Jun 2024 16:58:59 +0300 Subject: [PATCH 1/3] fix invalid ARIA role attribute on v4 --- packages/gallery/src/components/item/itemView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gallery/src/components/item/itemView.js b/packages/gallery/src/components/item/itemView.js index e40003620..272425f78 100644 --- a/packages/gallery/src/components/item/itemView.js +++ b/packages/gallery/src/components/item/itemView.js @@ -999,7 +999,7 @@ class ItemView extends React.Component { data-hash={hash} data-id={photoId} data-idx={idx} - role={this.getItemAriaRole()} + {...(this.getItemAriaRole() && { role: this.getItemAriaRole() })} data-hook="item-container" key={'item-container-' + id} style={this.getItemContainerStyles()} From 9a1c196dc705cb97732216838362c7e07aef76f7 Mon Sep 17 00:00:00 2001 From: Galpittel Date: Mon, 17 Jun 2024 17:01:57 +0300 Subject: [PATCH 2/3] change 'itemClick' test to match the new role change --- packages/gallery/tests/styleParams/itemClick.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gallery/tests/styleParams/itemClick.spec.js b/packages/gallery/tests/styleParams/itemClick.spec.js index c0efb5870..2bdd3806e 100644 --- a/packages/gallery/tests/styleParams/itemClick.spec.js +++ b/packages/gallery/tests/styleParams/itemClick.spec.js @@ -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(); }); }); From a7d2c14f7d60a8821400554c83926b7c6d05198f Mon Sep 17 00:00:00 2001 From: Galpittel Date: Tue, 18 Jun 2024 11:37:19 +0300 Subject: [PATCH 3/3] Store the result of this.getItemAriaRole() in a constant --- packages/gallery/src/components/item/itemView.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/gallery/src/components/item/itemView.js b/packages/gallery/src/components/item/itemView.js index 272425f78..7c89617a4 100644 --- a/packages/gallery/src/components/item/itemView.js +++ b/packages/gallery/src/components/item/itemView.js @@ -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 = (