From fd4e70d9374cfa9185d9d2ae390f55629954dfc4 Mon Sep 17 00:00:00 2001 From: noam-heller1 Date: Wed, 26 Jul 2023 15:52:18 +0300 Subject: [PATCH 1/4] fix alt text fallback --- packages/gallery/src/components/item/imageItem.js | 6 ++---- packages/gallery/src/components/item/itemView.js | 8 ++++---- packages/layouts/src/classes/galleryItem.js | 15 +++------------ 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/packages/gallery/src/components/item/imageItem.js b/packages/gallery/src/components/item/imageItem.js index c51a555eb7..6954126f03 100644 --- a/packages/gallery/src/components/item/imageItem.js +++ b/packages/gallery/src/components/item/imageItem.js @@ -115,7 +115,7 @@ class ImageItem extends React.Component { getImageElement() { const { - calculatedAlt, + alt, imageDimensions, createUrl, id, @@ -227,9 +227,7 @@ class ImageItem extends React.Component { data-hook="gallery-item-image-img" data-idx={idx} src={src} - alt={ - typeof calculatedAlt === 'string' ? calculatedAlt : 'untitled image' - } + alt={typeof alt === 'string' ? alt : 'untitled image'} onLoad={this.handleHighResImageLoad} loading={this.props.isPrerenderMode ? 'lazy' : 'eager'} style={{ diff --git a/packages/gallery/src/components/item/itemView.js b/packages/gallery/src/components/item/itemView.js index fa4f97ff03..b1341d2c35 100644 --- a/packages/gallery/src/components/item/itemView.js +++ b/packages/gallery/src/components/item/itemView.js @@ -398,7 +398,7 @@ class ItemView extends React.Component { getImageItem(imageDimensions) { const props = utils.pick(this.props, [ 'gotFirstScrollEvent', - 'calculatedAlt', + 'alt', 'title', 'description', 'id', @@ -779,12 +779,12 @@ class ItemView extends React.Component { } getItemAriaLabel() { - const { type, calculatedAlt, htmlContent, options } = this.props; + const { type, alt, htmlContent, options } = this.props; const mapTypeToLabel = { dummy: '', text: htmlContent, - video: calculatedAlt || 'Untitled video', - image: calculatedAlt || 'Untitled image', + video: alt || 'Untitled video', + image: alt || 'Untitled image', }; const label = mapTypeToLabel[type]; return label + (options.isStoreGallery ? ', Buy Now' : ''); diff --git a/packages/layouts/src/classes/galleryItem.js b/packages/layouts/src/classes/galleryItem.js index fa17e9976d..4417522f05 100644 --- a/packages/layouts/src/classes/galleryItem.js +++ b/packages/layouts/src/classes/galleryItem.js @@ -129,7 +129,6 @@ class GalleryItem { isVideoPlaceholder: this.isVideoPlaceholder, url: this.url, alt: this.alt, - calculatedAlt: this.calculatedAlt, htmlContent: this.htmlContent, directLink: this.directLink, directShareLink: this.directShareLink, @@ -691,22 +690,14 @@ class GalleryItem { ); } - get calculatedAlt() { - return ( - (utils.isMeaningfulString(this.alt) && this.alt) || - this.title || - this.description || - this.fileName || - '' - ); - } - get htmlContent() { return this.html?.replace(/<[^<>]*>/g, '').trim(); } get alt() { - return this.metadata.alt || ''; + return ( + (utils.isMeaningfulString(this.metadata.alt) && this.metadata.alt) || '' + ); } set alt(value) { From a65b84792aca0411292c1cb931cd33d4eca62feb Mon Sep 17 00:00:00 2001 From: noam-heller1 Date: Thu, 27 Jul 2023 12:43:57 +0300 Subject: [PATCH 2/4] fix schema checks --- packages/lib/buildScripts/getSchema.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/lib/buildScripts/getSchema.js b/packages/lib/buildScripts/getSchema.js index 7f4f131398..e5013f683f 100644 --- a/packages/lib/buildScripts/getSchema.js +++ b/packages/lib/buildScripts/getSchema.js @@ -11,6 +11,7 @@ function getSchemaFromTypes(typesFileAbsolutePath) { // optionally pass ts compiler options const compilerOptions = { strictNullChecks: true, + skipLibCheck: true, }; // optionally pass a base path From db28d20b1fca219a30cb0f068e408f7a113f5da0 Mon Sep 17 00:00:00 2001 From: noam-heller1 Date: Sun, 30 Jul 2023 15:46:45 +0300 Subject: [PATCH 3/4] fix PR comments --- packages/gallery/src/components/item/imageItem.js | 2 +- packages/gallery/src/components/item/itemView.js | 4 ++-- packages/layouts/src/classes/galleryItem.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/gallery/src/components/item/imageItem.js b/packages/gallery/src/components/item/imageItem.js index 6954126f03..864433c194 100644 --- a/packages/gallery/src/components/item/imageItem.js +++ b/packages/gallery/src/components/item/imageItem.js @@ -227,7 +227,7 @@ class ImageItem extends React.Component { data-hook="gallery-item-image-img" data-idx={idx} src={src} - alt={typeof alt === 'string' ? alt : 'untitled image'} + alt={typeof alt === 'string' ? alt : ''} onLoad={this.handleHighResImageLoad} loading={this.props.isPrerenderMode ? 'lazy' : 'eager'} style={{ diff --git a/packages/gallery/src/components/item/itemView.js b/packages/gallery/src/components/item/itemView.js index b1341d2c35..471af0ae68 100644 --- a/packages/gallery/src/components/item/itemView.js +++ b/packages/gallery/src/components/item/itemView.js @@ -783,8 +783,8 @@ class ItemView extends React.Component { const mapTypeToLabel = { dummy: '', text: htmlContent, - video: alt || 'Untitled video', - image: alt || 'Untitled image', + video: alt || '', + image: alt || '', }; const label = mapTypeToLabel[type]; return label + (options.isStoreGallery ? ', Buy Now' : ''); diff --git a/packages/layouts/src/classes/galleryItem.js b/packages/layouts/src/classes/galleryItem.js index 4417522f05..8b0da049d4 100644 --- a/packages/layouts/src/classes/galleryItem.js +++ b/packages/layouts/src/classes/galleryItem.js @@ -696,7 +696,7 @@ class GalleryItem { get alt() { return ( - (utils.isMeaningfulString(this.metadata.alt) && this.metadata.alt) || '' + (this.metadata.alt && utils.isMeaningfulString(this.metadata.alt)) || '' ); } From 015c8b28501cda87c4a4a5da8e23f25647769d12 Mon Sep 17 00:00:00 2001 From: noam-heller1 Date: Sun, 30 Jul 2023 16:05:21 +0300 Subject: [PATCH 4/4] revert PR comment fix --- packages/layouts/src/classes/galleryItem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/layouts/src/classes/galleryItem.js b/packages/layouts/src/classes/galleryItem.js index 8b0da049d4..4417522f05 100644 --- a/packages/layouts/src/classes/galleryItem.js +++ b/packages/layouts/src/classes/galleryItem.js @@ -696,7 +696,7 @@ class GalleryItem { get alt() { return ( - (this.metadata.alt && utils.isMeaningfulString(this.metadata.alt)) || '' + (utils.isMeaningfulString(this.metadata.alt) && this.metadata.alt) || '' ); }