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

override default anchor style with parent style #5060

Merged
Merged
Changes from 1 commit
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 @@ -70,6 +70,7 @@ function AnchorRenderer({tnode, key, style}) {
// An auth token is needed to download Expensify chat attachments
const isAttachment = Boolean(htmlAttribs['data-expensify-source']);
const fileName = lodashGet(tnode, 'domNode.children[0].data', '');
const parentStyle = lodashGet(tnode, 'parent.styles.nativeTextRet', {});
Copy link
Contributor

Choose a reason for hiding this comment

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

This code looks OK to me, but seems potentially brittle because it's relying on some internal detail of the html library we are using.

e.g. I'm not really sure what parent.styles.nativeTextRet is or whether we can depend on it to always exist? I also don't have an alternative suggestion so I'm fine with this for now - but would have preferred more comments in the code to add context about why we are doing this.


return (
<AnchorForCommentsOnly
Expand All @@ -83,7 +84,7 @@ function AnchorRenderer({tnode, key, style}) {
// eslint-disable-next-line react/jsx-props-no-multi-spaces
target={htmlAttribs.target || '_blank'}
rel={htmlAttribs.rel || 'noopener noreferrer'}
style={style}
style={{...style, ...parentStyle}}
key={key}
fileName={fileName}
>
Expand Down