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 anchor text can't show both underline (link style) and line through (delete style while offline) on iOS #38985

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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ function AnchorRenderer({tnode, style, key}: AnchorRendererProps) {
);
}

const hasStrikethroughStyle = 'textDecorationLine' in parentStyle && parentStyle.textDecorationLine === 'line-through';
const textDecorationLineStyle = hasStrikethroughStyle ? styles.underlineLineThrough : {};

return (
<AnchorForCommentsOnly
href={attrHref}
Expand All @@ -65,12 +68,30 @@ function AnchorRenderer({tnode, style, key}: AnchorRendererProps) {
// eslint-disable-next-line react/jsx-props-no-multi-spaces
target={htmlAttribs.target || '_blank'}
rel={htmlAttribs.rel || 'noopener noreferrer'}
style={[style, parentStyle, styles.textUnderlinePositionUnder, styles.textDecorationSkipInkNone]}
style={[style, parentStyle, textDecorationLineStyle, styles.textUnderlinePositionUnder, styles.textDecorationSkipInkNone]}
key={key}
// Only pass the press handler for internal links. For public links or whitelisted internal links fallback to default link handling
onPress={internalNewExpensifyPath || internalExpensifyPath ? () => Link.openLink(attrHref, environmentURL, isAttachment) : undefined}
>
<TNodeChildrenRenderer tnode={tnode} />
<TNodeChildrenRenderer
tnode={tnode}
renderChild={(props) => {
if (props.childTnode.tagName === 'br') {
return <Text key={props.key}>{'\n'}</Text>;
}
if (props.childTnode.type === 'text') {
return (
<Text
key={props.key}
style={[props.childTnode.getNativeStyles(), parentStyle, textDecorationLineStyle, styles.textUnderlinePositionUnder, styles.textDecorationSkipInkNone]}
>
{props.childTnode.data}
</Text>
);
}
return props.childElement;
}}
/>
</AnchorForCommentsOnly>
);
}
Expand Down
4 changes: 4 additions & 0 deletions src/styles/utils/textDecorationLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ export default {
textDecorationLine: 'line-through',
textDecorationStyle: 'solid',
},
underlineLineThrough: {
textDecorationLine: 'underline line-through',
textDecorationStyle: 'solid',
},
} satisfies Record<string, TextStyle>;
Loading