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: Mention does not show beam on selection #20447

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 @@ -9,6 +9,7 @@ import htmlRendererPropTypes from './htmlRendererPropTypes';
import withCurrentUserPersonalDetails from '../../withCurrentUserPersonalDetails';
import personalDetailsPropType from '../../../pages/personalDetailsPropType';
import * as StyleUtils from '../../../styles/StyleUtils';
import TextLink from '../../TextLink';

const propTypes = {
...htmlRendererPropTypes,
Expand All @@ -30,22 +31,23 @@ function MentionUserRenderer(props) {
const defaultRendererProps = _.omit(props, ['TDefaultRenderer', 'style']);

// We need to remove the leading @ from data as it is not part of the login
const loginWhithoutLeadingAt = props.tnode.data.slice(1);
const loginWithoutLeadingAt = props.tnode.data.slice(1);

const isOurMention = loginWhithoutLeadingAt === props.currentUserPersonalDetails.login;
const isOurMention = loginWithoutLeadingAt === props.currentUserPersonalDetails.login;

return (
<Text>
<Tooltip text={loginWhithoutLeadingAt}>
<Text
<Tooltip text={loginWithoutLeadingAt}>
<TextLink
// eslint-disable-next-line react/jsx-props-no-spreading
{...defaultRendererProps}
href={ROUTES.getDetailsRoute(loginWithoutLeadingAt)}
color={StyleUtils.getMentionTextColor(isOurMention)}
style={[_.omit(props.style, 'color'), StyleUtils.getMentionStyle(isOurMention)]}
onPress={() => showUserDetails(loginWhithoutLeadingAt)}
onPress={() => showUserDetails(loginWithoutLeadingAt)}
>
<TNodeChildrenRenderer tnode={props.tnode} />
</Text>
</TextLink>
</Tooltip>
</Text>
);
Expand Down
3 changes: 3 additions & 0 deletions src/components/TextLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const defaultProps = {
};

function TextLink(props) {
const rest = _.omit(props, _.keys(propTypes));
Copy link
Contributor

Choose a reason for hiding this comment

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

I just want to make sure I understand what is happening here...

When we call TextLink and pass props, the rest variable is going to contain all the props that are not in the propTyles defined above.

Then, we are adding the props that are in rest to the props that we are sending to Text below.

Is that all correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is.

const additionalStyles = _.isArray(props.style) ? props.style : [props.style];

/**
Expand Down Expand Up @@ -64,6 +65,8 @@ function TextLink(props) {
onPress={openLink}
onMouseDown={props.onMouseDown}
onKeyDown={openLinkIfEnterKeyPressed}
// eslint-disable-next-line react/jsx-props-no-spreading
{...rest}
>
{props.children}
</Text>
Expand Down