Conversation
|
Warning: Component files have been updated but no migrations have been added. See https://github.com/yext/visual-editor/blob/main/packages/visual-editor/src/components/migrations/README.md for more information. |
WalkthroughThe PR widens FooterLogoSlot's public image prop to accept ImageType and ComplexImageType in addition to AssetImageType and TranslatableAssetImage. Internal resolution now normalizes various image shapes into a simplified image, uses a shared getImageUrl(image, locale) to compute the URL, and uses getImageAltText(image, locale, document) for alt text. The editor field config for the slot changes from Sequence Diagram(s)sequenceDiagram
participant Editor as Editor (slot data)
participant Footer as FooterLogoSlot
participant Resolver as resolveComponentData
participant Utils as getImageUrl / getImageAltText
participant ImageCmp as Image component
Editor->>Footer: provide data.image (various image shapes)
Footer->>Resolver: resolveComponentData(data.image)
Resolver-->>Footer: resolvedImage (ImageType|ComplexImageType|TranslatableAssetImage|...)
Footer->>Utils: getImageUrl(resolvedImage, locale)
Utils-->>Footer: imageUrl
Footer->>Utils: getImageAltText(resolvedImage, locale, streamDocument)
Utils-->>Footer: altText
Footer->>ImageCmp: render with simplifiedImage / imageUrl / altText
ImageCmp-->>Footer: rendered <img>
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/visual-editor/src/components/footer/FooterLogoSlot.tsx (1)
120-138:⚠️ Potential issue | 🟠 MajorDefault
constantValuestructure usesTranslatableStringforalternateText— confirm this is handled correctly downstream.Line 129 sets
alternateText: { en: "Logo", hasLocalizedValue: "true" }, which is aTranslatableStringobject. Since theuseMemocasts it toImageType(which expectsalternateText?: string), this default will exhibit the[object Object]alt-text issue mentioned above until thealternateTextresolution is fixed.
🤖 Fix all issues with AI agents
In `@packages/visual-editor/src/components/footer/FooterLogoSlot.tsx`:
- Around line 33-60: The image alternateText (AssetImageType.alternateText) is
still a TranslatableString object and must be localized before use; update the
image resolution in FooterLogoSlot by calling
resolveComponentData(image?.alternateText, i18n.language, streamDocument)
(similar to FooterUtilityImagesSlot/PhotoGalleryWrapper) and pass that resolved
string to ariaLabel/fallback logic instead of the raw object so ariaLabel
receives a string or undefined.
🧹 Nitpick comments (1)
packages/visual-editor/src/components/footer/FooterLogoSlot.tsx (1)
44-56: Unsafe narrowing: bothAssetImageTypeandImageTypehave"url", so the first branch swallows asset images without special handling.The
"url" in resolvedImagecheck (line 44) matches bothImageTypeandAssetImageType. If you intend different handling forAssetImageType(e.g., extracting the localizedalternateText), you should check for the more specific type first:+ // Check for AssetImageType first (has assetImage or TranslatableString alternateText) + if ("url" in resolvedImage && "assetImage" in resolvedImage) { + // Handle AssetImageType: resolve alternateText from TranslatableString + ... + } + if ("url" in resolvedImage) { return resolvedImage as ImageType; }Otherwise the
AssetImageType-specific fields (likeassetImageand the translatablealternateText) are silently discarded.
AI was outputting weird data for the footer logo -> the type is set to YextEntityField but the field configuration was a non-entity field image