Prevent clicking stuff in statuses from expanding the status

This commit is contained in:
Alex Gleason 2022-04-16 11:53:00 -05:00
parent 1fb8d162db
commit bf8de20e0d
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 16 additions and 1 deletions

View File

@ -87,6 +87,7 @@ const StatusContent: React.FC<IStatusContent> = ({ status, expanded = false, onE
const onMentionClick = (mention: Mention, e: MouseEvent) => {
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
e.stopPropagation();
history.push(`/@${mention.acct}`);
}
};
@ -96,10 +97,16 @@ const StatusContent: React.FC<IStatusContent> = ({ status, expanded = false, onE
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
e.preventDefault();
e.stopPropagation();
history.push(`/tags/${hashtag}`);
}
};
/** For regular links, just stop propogation */
const onLinkClick = (e: MouseEvent) => {
e.stopPropagation();
};
const updateStatusLinks = () => {
if (!node.current) return;
@ -124,6 +131,7 @@ const StatusContent: React.FC<IStatusContent> = ({ status, expanded = false, onE
link.addEventListener('click', onHashtagClick.bind(link, link.text), false);
} else {
link.setAttribute('title', link.href);
link.addEventListener('click', onLinkClick.bind(link), false);
}
});
};

View File

@ -252,7 +252,14 @@ export default class Card extends React.PureComponent {
}
return (
<a href={card.get('url')} className={className} target='_blank' rel='noopener' ref={this.setRef}>
<a
href={card.get('url')}
className={className}
target='_blank'
rel='noopener'
ref={this.setRef}
onClick={e => e.stopPropagation()}
>
{embed}
{description}
</a>