From d2dca826dd06c78e562a9eaf96c9993d6bbe2e08 Mon Sep 17 00:00:00 2001 From: Echo Date: Thu, 5 Feb 2026 13:58:00 +0100 Subject: [PATCH] Cancel quote button appearing in all statuses (#37742) --- app/javascript/mastodon/components/status.jsx | 3 +- .../mastodon/components/status/header.tsx | 7 +++- .../mastodon/components/status/types.ts | 36 +++++++++++++++++++ .../mastodon/components/status_quoted.tsx | 16 +++++---- 4 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 app/javascript/mastodon/components/status/types.ts diff --git a/app/javascript/mastodon/components/status.jsx b/app/javascript/mastodon/components/status.jsx index 59f6f7d07eb..88b61682293 100644 --- a/app/javascript/mastodon/components/status.jsx +++ b/app/javascript/mastodon/components/status.jsx @@ -140,6 +140,7 @@ class Status extends ImmutablePureComponent { 'hidden', 'unread', 'pictureInPicture', + 'headerRenderFn', ]; state = { @@ -556,7 +557,7 @@ class Status extends ImmutablePureComponent { const {statusContentProps, hashtagBar} = getHashtagBarForStatus(status); const header = this.props.headerRenderFn - ? this.props.headerRenderFn({ status, account, avatarSize, messages, onHeaderClick: this.handleHeaderClick }) + ? this.props.headerRenderFn({ status, account, avatarSize, messages, onHeaderClick: this.handleHeaderClick, statusProps: this.props }) : ( ; } -export type StatusHeaderRenderFn = (args: StatusHeaderProps) => ReactNode; +export type StatusHeaderRenderFn = ( + args: StatusHeaderProps, + statusProps?: StatusProps, +) => ReactNode; export const StatusHeader: FC = ({ status, diff --git a/app/javascript/mastodon/components/status/types.ts b/app/javascript/mastodon/components/status/types.ts new file mode 100644 index 00000000000..98fdbb9acf6 --- /dev/null +++ b/app/javascript/mastodon/components/status/types.ts @@ -0,0 +1,36 @@ +import type { ComponentClass, MouseEventHandler, ReactNode } from 'react'; + +import type { Account } from '@/mastodon/models/account'; + +import type { StatusHeaderRenderFn } from './header'; + +// Taken from the Status component. +export interface StatusProps { + account?: Account; + children?: ReactNode; + previousId?: string; + rootId?: string; + onClick?: MouseEventHandler; + muted?: boolean; + hidden?: boolean; + unread?: boolean; + showThread?: boolean; + showActions?: boolean; + isQuotedPost?: boolean; + shouldHighlightOnMount?: boolean; + getScrollPosition?: () => null | { height: number; top: number }; + updateScrollBottom?: (snapshot: number) => void; + cacheMediaWidth?: (width: number) => void; + cachedMediaWidth?: number; + scrollKey?: string; + skipPrepend?: boolean; + avatarSize?: number; + unfocusable?: boolean; + headerRenderFn?: StatusHeaderRenderFn; + contextType?: string; +} + +export type StatusComponent = ComponentClass< + StatusProps, + { showMedia?: boolean; showDespiteFilter?: boolean } +>; diff --git a/app/javascript/mastodon/components/status_quoted.tsx b/app/javascript/mastodon/components/status_quoted.tsx index 8effec874f2..1fffe26c08b 100644 --- a/app/javascript/mastodon/components/status_quoted.tsx +++ b/app/javascript/mastodon/components/status_quoted.tsx @@ -226,13 +226,15 @@ export const QuotedStatus: React.FC = ({ const headerRenderFn: StatusHeaderRenderFn = useCallback( (props) => ( - + {onQuoteCancel && ( + + )} ), [intl, onQuoteCancel],