Repository navigation
fix(ui-elements): prevent preview cover image tiling and constrain card width - #1481
Open
swarnendusahu10-dotcom wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1480
Problem
When rendering UIKit
previewblocks (such as GitHub PR/issue link previews), two layout issues caused the preview image to tile across the viewport:MessageGenericPreviewCoverImageappliedbackground-image: url(...)withoutbackground-repeat: no-repeat,background-size: cover, orbackground-position: center, causing the image to tile horizontally and vertically whenever the container exceeded the image's intrinsic size (e.g., on wide viewports or when zoomed out).MessageGenericPreviewhad nomax-widthconstraint, allowing the preview card to stretch across the full message width and expand the aspect-ratio spacer proportionally.urlinterpolation inurl(${url})and unguardedheight / widthdivision could cause broken styles on invalid URLs or zero/missing dimensions.Changes
packages/ui-elements/src/components/MessageGenericPreview/MessageGenericPreviewCoverImage.js:background-repeat: no-repeat,background-position: center,background-size: cover,width: 100%, andoverflow: hidden.getSafeImageUrl()to allow onlyhttp:/https:URLs and safely escape the URL viaJSON.stringify().aspectRatioPaddingagainst missing,0, or non-finitewidth/heightvalues.packages/ui-elements/src/components/MessageGenericPreview/MessageGenericPreview.styles.js:width: 100%; max-width: 368px;(matching Rocket.Chat's preview card width and scaling cleanly on mobile viewports).packages/ui-elements/src/components/MessageGenericPreview/MessageGenericPreviewContent.js:min-width: 0; flex: 1; overflow-wrap: break-word;on.ec-message-generic-preview__content-wrapperso long titles/URLs wrap cleanly on narrow mobile screens..changeset/fix-preview-cover-image-tiling.md: Added patch changeset for@embeddedchat/ui-elements.Verification
@embeddedchat/ui-elementsRollup build (yarn build): exited cleanly with code 0.