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: clicking title of url preview don't open site #21717

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
10 changes: 6 additions & 4 deletions src/pages/home/report/LinkPreviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import _ from 'underscore';
import {uniqBy} from 'lodash';
import useWindowDimensions from '../../../hooks/useWindowDimensions';
import Text from '../../../components/Text';
import TextLink from '../../../components/TextLink';
import * as StyleUtils from '../../../styles/StyleUtils';
import styles from '../../../styles/styles';
import variables from '../../../styles/variables';
import colors from '../../../styles/colors';
Expand Down Expand Up @@ -103,13 +105,13 @@ function LinkPreviewer(props) {
)}
</View>
{!_.isEmpty(title) && (
<Text
<TextLink
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We replaced the Text component to TextLink to make it clickable, but we didn't check the clickable area for the pv2 padding and full width area. This caused a regression here.

fontSize={variables.fontSizeNormal}
style={styles.pv2}
color={colors.blueLinkPreview}
style={[styles.pv2, StyleUtils.getTextColorStyle(colors.blueLinkPreview)]}
href={url}
>
{title}
</Text>
</TextLink>
)}
{!_.isEmpty(description) && <Text fontSize={variables.fontSizeNormal}>{description}</Text>}
{!_.isEmpty(image) && IMAGE_TYPES.includes(image.type) && (
Expand Down
13 changes: 13 additions & 0 deletions src/styles/StyleUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,18 @@ function getBackgroundColorStyle(backgroundColor) {
};
}

/**
* Returns a style for text color
*
* @param {String} color
* @returns {Object}
*/
function getTextColorStyle(color) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this vs just using color={colors.blueLinkPreview}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thesahindia pointed it out in the previous comment #21717 (comment)

You will need to pass the color in style prop because we don't have the color prop in TextLink component

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for clarifying!

return {
color,
};
}

/**
* Returns a style with the specified borderColor
*
Expand Down Expand Up @@ -1230,6 +1242,7 @@ export {
getAutoGrowHeightInputStyle,
getBackgroundAndBorderStyle,
getBackgroundColorStyle,
getTextColorStyle,
getBorderColorStyle,
getBackgroundColorWithOpacityStyle,
getBadgeColorStyle,
Expand Down