Improve click handling
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
8208518e2c
commit
4c37afa34f
10 changed files with 40 additions and 21 deletions
|
@ -22,7 +22,13 @@ const InstanceFavicon: React.FC<IInstanceFavicon> = ({ account }) => {
|
|||
|
||||
const handleClick: React.MouseEventHandler = (e) => {
|
||||
e.stopPropagation();
|
||||
history.push(`/timeline/${account.domain}`);
|
||||
|
||||
const timelineUrl = `/timeline/${account.domain}`;
|
||||
if (!(e.ctrlKey || e.metaKey)) {
|
||||
history.push(timelineUrl);
|
||||
} else {
|
||||
window.open(timelineUrl, '_blank');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -219,7 +225,7 @@ const Account = ({
|
|||
<Text tag='span' theme='muted' size='sm'>·</Text>
|
||||
|
||||
{timestampUrl ? (
|
||||
<Link to={timestampUrl} className='hover:underline'>
|
||||
<Link to={timestampUrl} className='hover:underline' onClick={(event) => event.stopPropagation()}>
|
||||
<RelativeTimestamp timestamp={timestamp} theme='muted' size='sm' className='whitespace-nowrap' futureDate={futureTimestamp} />
|
||||
</Link>
|
||||
) : (
|
||||
|
|
|
@ -143,12 +143,14 @@ class DropdownMenu extends React.PureComponent<IDropdownMenu, IDropdownMenuState
|
|||
|
||||
this.props.onClose();
|
||||
|
||||
if (typeof action === 'function') {
|
||||
e.preventDefault();
|
||||
action(e);
|
||||
} else if (to) {
|
||||
e.stopPropagation();
|
||||
|
||||
if (to) {
|
||||
e.preventDefault();
|
||||
this.props.history.push(to);
|
||||
} else if (typeof action === 'function') {
|
||||
e.preventDefault();
|
||||
action(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,6 +194,7 @@ class DropdownMenu extends React.PureComponent<IDropdownMenu, IDropdownMenuState
|
|||
data-index={i}
|
||||
target={newTab ? '_blank' : undefined}
|
||||
data-method={isLogout ? 'delete' : undefined}
|
||||
title={text}
|
||||
>
|
||||
{icon && <SvgIcon src={icon} className='mr-3 h-5 w-5 flex-none' />}
|
||||
|
||||
|
|
|
@ -44,7 +44,12 @@ const QuotedStatus: React.FC<IQuotedStatus> = ({ status, onCancel, compose }) =>
|
|||
const account = status.account as AccountEntity;
|
||||
|
||||
if (!compose && e.button === 0) {
|
||||
history.push(`/@${account.acct}/posts/${status.id}`);
|
||||
const statusUrl = `/@${account.acct}/posts/${status.id}`;
|
||||
if (!(e.ctrlKey || e.metaKey)) {
|
||||
history.push(statusUrl);
|
||||
} else {
|
||||
window.open(statusUrl, '_blank');
|
||||
}
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
|
|
|
@ -459,7 +459,6 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
|||
text: intl.formatMessage(messages.admin_status),
|
||||
href: `/pleroma/admin/#/statuses/${status.id}/`,
|
||||
icon: require('@tabler/icons/pencil.svg'),
|
||||
action: (event) => event.stopPropagation(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ const StatusReplyMentions: React.FC<IStatusReplyMentions> = ({ status, hoverable
|
|||
// The typical case with a reply-to and a list of mentions.
|
||||
const accounts = to.slice(0, 2).map(account => {
|
||||
const link = (
|
||||
<Link to={`/@${account.acct}`} className='reply-mentions__account'>@{account.username}</Link>
|
||||
<Link to={`/@${account.acct}`} className='reply-mentions__account' onClick={(e) => e.stopPropagation()}>@{account.username}</Link>
|
||||
);
|
||||
|
||||
if (hoverable) {
|
||||
|
|
|
@ -84,6 +84,8 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
|
||||
const actualStatus = getActualStatus(status);
|
||||
|
||||
const statusUrl = `/@${actualStatus.getIn(['account', 'acct'])}/posts/${actualStatus.id}`;
|
||||
|
||||
// Track height changes we know about to compensate scrolling.
|
||||
useEffect(() => {
|
||||
didShowCard.current = Boolean(!muted && !hidden && status?.card);
|
||||
|
@ -97,11 +99,17 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
setShowMedia(!showMedia);
|
||||
};
|
||||
|
||||
const handleClick = (): void => {
|
||||
if (onClick) {
|
||||
onClick();
|
||||
const handleClick = (e?: React.MouseEvent): void => {
|
||||
e?.stopPropagation();
|
||||
|
||||
if (!e || !(e.ctrlKey || e.metaKey)) {
|
||||
if (onClick) {
|
||||
onClick();
|
||||
} else {
|
||||
history.push(statusUrl);
|
||||
}
|
||||
} else {
|
||||
history.push(`/@${actualStatus.getIn(['account', 'acct'])}/posts/${actualStatus.id}`);
|
||||
window.open(statusUrl, '_blank');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -145,7 +153,7 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
};
|
||||
|
||||
const handleHotkeyOpen = (): void => {
|
||||
history.push(`/@${actualStatus.getIn(['account', 'acct'])}/posts/${actualStatus.id}`);
|
||||
history.push(statusUrl);
|
||||
};
|
||||
|
||||
const handleHotkeyOpenProfile = (): void => {
|
||||
|
@ -292,8 +300,6 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
react: handleHotkeyReact,
|
||||
};
|
||||
|
||||
const statusUrl = `/@${actualStatus.getIn(['account', 'acct'])}/posts/${actualStatus.id}`;
|
||||
|
||||
const accountAction = props.accountAction || reblogElement;
|
||||
|
||||
const inReview = actualStatus.visibility === 'self';
|
||||
|
@ -307,7 +313,7 @@ const Status: React.FC<IStatus> = (props) => {
|
|||
data-featured={featured ? 'true' : null}
|
||||
aria-label={textForScreenReader(intl, actualStatus, rebloggedByText)}
|
||||
ref={node}
|
||||
onClick={() => history.push(statusUrl)}
|
||||
onClick={handleClick}
|
||||
role='link'
|
||||
>
|
||||
{featured && (
|
||||
|
|
|
@ -147,7 +147,7 @@ const StatusContent: React.FC<IStatusContent> = ({ status, onClick, collapsable
|
|||
return;
|
||||
}
|
||||
|
||||
if (deltaX + deltaY < 5 && e.button === 0 && onClick) {
|
||||
if (deltaX + deltaY < 5 && e.button === 0 && !(e.ctrlKey || e.metaKey) && onClick) {
|
||||
onClick();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ const TranslateButton: React.FC<ITranslateButton> = ({ status }) => {
|
|||
|
||||
const me = useAppSelector((state) => state.me);
|
||||
|
||||
const renderTranslate = /* translationEnabled && */ me && ['public', 'unlisted'].includes(status.visibility) && status.contentHtml.length > 0 && status.language !== null && intl.locale !== status.language;
|
||||
const renderTranslate = me && ['public', 'unlisted'].includes(status.visibility) && status.contentHtml.length > 0 && status.language !== null && intl.locale !== status.language;
|
||||
|
||||
const handleTranslate: React.MouseEventHandler<HTMLButtonElement> = (e) => {
|
||||
e.stopPropagation();
|
||||
|
|
|
@ -40,7 +40,7 @@ const ActionsModal: React.FC<IActionsModal> = ({ status, actions, onClick, onClo
|
|||
className={classNames('w-full', { active, destructive })}
|
||||
data-method={isLogout ? 'delete' : null}
|
||||
>
|
||||
{icon && <Icon className='min-w-fit' title={text} src={icon} role='presentation' tabIndex={-1} />}
|
||||
{icon && <Icon title={text} src={icon} role='presentation' tabIndex={-1} />}
|
||||
<div>
|
||||
<div className={classNames({ 'actions-modal__item-label': !!meta })}>{text}</div>
|
||||
<div>{meta}</div>
|
||||
|
|
|
@ -311,7 +311,7 @@
|
|||
}
|
||||
|
||||
.svg-icon:first-child {
|
||||
@apply w-5 h-5 mr-2.5;
|
||||
@apply min-w-[1.25rem] w-5 h-5 mr-2.5;
|
||||
|
||||
svg {
|
||||
stroke-width: 1.5;
|
||||
|
|
Loading…
Reference in a new issue