sforkowany z mirror/soapbox
Disallow status card nested hovering
rodzic
01e643e4f6
commit
3e531b6827
|
@ -70,6 +70,7 @@ export const StatusHoverCard: React.FC<IStatusHoverCard> = ({ visible = true })
|
||||||
<StatusContainer
|
<StatusContainer
|
||||||
key={statusId}
|
key={statusId}
|
||||||
id={statusId}
|
id={statusId}
|
||||||
|
hoverable={false}
|
||||||
hideActionBar
|
hideActionBar
|
||||||
muted
|
muted
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -11,9 +11,10 @@ import type { Account, Status } from 'soapbox/types/entities';
|
||||||
|
|
||||||
interface IStatusReplyMentions {
|
interface IStatusReplyMentions {
|
||||||
status: Status,
|
status: Status,
|
||||||
|
hoverable?: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
const StatusReplyMentions: React.FC<IStatusReplyMentions> = ({ status }) => {
|
const StatusReplyMentions: React.FC<IStatusReplyMentions> = ({ status, hoverable = true }) => {
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const handleOpenMentionsModal: React.MouseEventHandler<HTMLSpanElement> = (e) => {
|
const handleOpenMentionsModal: React.MouseEventHandler<HTMLSpanElement> = (e) => {
|
||||||
|
@ -47,11 +48,21 @@ const StatusReplyMentions: React.FC<IStatusReplyMentions> = ({ status }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The typical case with a reply-to and a list of mentions.
|
// The typical case with a reply-to and a list of mentions.
|
||||||
const accounts = to.slice(0, 2).map(account => (
|
const accounts = to.slice(0, 2).map(account => {
|
||||||
<HoverRefWrapper key={account.id} accountId={account.id} inline>
|
const link = (
|
||||||
<Link to={`/@${account.acct}`} className='reply-mentions__account'>@{account.username}</Link>
|
<Link to={`/@${account.acct}`} className='reply-mentions__account'>@{account.username}</Link>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hoverable) {
|
||||||
|
return (
|
||||||
|
<HoverRefWrapper key={account.id} accountId={account.id} inline>
|
||||||
|
{link}
|
||||||
</HoverRefWrapper>
|
</HoverRefWrapper>
|
||||||
)).toArray();
|
);
|
||||||
|
} else {
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
}).toArray();
|
||||||
|
|
||||||
if (to.size > 2) {
|
if (to.size > 2) {
|
||||||
accounts.push(
|
accounts.push(
|
||||||
|
@ -68,7 +79,9 @@ const StatusReplyMentions: React.FC<IStatusReplyMentions> = ({ status }) => {
|
||||||
defaultMessage='<hover>Replying to</hover> {accounts}'
|
defaultMessage='<hover>Replying to</hover> {accounts}'
|
||||||
values={{
|
values={{
|
||||||
accounts: <FormattedList type='conjunction' value={accounts} />,
|
accounts: <FormattedList type='conjunction' value={accounts} />,
|
||||||
hover: (children: React.ReactNode) => (
|
hover: (children: React.ReactNode) => {
|
||||||
|
if (hoverable) {
|
||||||
|
return (
|
||||||
<HoverStatusWrapper statusId={status.in_reply_to_id} inline>
|
<HoverStatusWrapper statusId={status.in_reply_to_id} inline>
|
||||||
<span
|
<span
|
||||||
key='hoverstatus'
|
key='hoverstatus'
|
||||||
|
@ -78,7 +91,11 @@ const StatusReplyMentions: React.FC<IStatusReplyMentions> = ({ status }) => {
|
||||||
{children}
|
{children}
|
||||||
</span>
|
</span>
|
||||||
</HoverStatusWrapper>
|
</HoverStatusWrapper>
|
||||||
),
|
);
|
||||||
|
} else {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -94,6 +94,7 @@ interface IStatus extends RouteComponentProps {
|
||||||
featured?: boolean,
|
featured?: boolean,
|
||||||
withDismiss?: boolean,
|
withDismiss?: boolean,
|
||||||
hideActionBar?: boolean,
|
hideActionBar?: boolean,
|
||||||
|
hoverable?: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IStatusState {
|
interface IStatusState {
|
||||||
|
@ -106,6 +107,7 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
focusable: true,
|
focusable: true,
|
||||||
|
hoverable: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
didShowCard = false;
|
didShowCard = false;
|
||||||
|
@ -481,6 +483,7 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
|
||||||
action={reblogElement}
|
action={reblogElement}
|
||||||
hideActions={!reblogElement}
|
hideActions={!reblogElement}
|
||||||
showEdit={!!status.edited_at}
|
showEdit={!!status.edited_at}
|
||||||
|
showProfileHoverCard={this.props.hoverable}
|
||||||
/>
|
/>
|
||||||
</HStack>
|
</HStack>
|
||||||
</div>
|
</div>
|
||||||
|
@ -492,7 +495,10 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<StatusReplyMentions status={this._properStatus()} />
|
<StatusReplyMentions
|
||||||
|
status={this._properStatus()}
|
||||||
|
hoverable={this.props.hoverable}
|
||||||
|
/>
|
||||||
|
|
||||||
<StatusContent
|
<StatusContent
|
||||||
status={status}
|
status={status}
|
||||||
|
|
Ładowanie…
Reference in New Issue