FormattedMessage must be used directly (#20982)

* `FormattedMessage` must be used directly

* rollback
This commit is contained in:
Yamagishi Kazutoshi 2022-12-16 00:20:46 +09:00 committed by GitHub
parent 3a59ffde8d
commit 58200132d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 16 deletions

View file

@ -24,16 +24,6 @@ const mapStateToProps = state => ({
isSearching: state.getIn(['search', 'submitted']) || !showTrends, isSearching: state.getIn(['search', 'submitted']) || !showTrends,
}); });
// Fix strange bug on Safari where <span> (rendered by FormattedMessage) disappears
// after clicking around Explore top bar (issue #20885).
// Removing width=100% from <a> also fixes it, as well as replacing <span> with <div>
// We're choosing to wrap span with div to keep the changes local only to this tool bar.
const WrapFormattedMessage = ({ children, ...props }) => <div><FormattedMessage {...props}>{children}</FormattedMessage></div>;
WrapFormattedMessage.propTypes = {
children: PropTypes.any,
};
export default @connect(mapStateToProps) export default @connect(mapStateToProps)
@injectIntl @injectIntl
class Explore extends React.PureComponent { class Explore extends React.PureComponent {
@ -78,12 +68,22 @@ class Explore extends React.PureComponent {
{isSearching ? ( {isSearching ? (
<SearchResults /> <SearchResults />
) : ( ) : (
<React.Fragment> <>
<div className='account__section-headline'> <div className='account__section-headline'>
<NavLink exact to='/explore'><WrapFormattedMessage id='explore.trending_statuses' defaultMessage='Posts' /></NavLink> <NavLink exact to='/explore'>
<NavLink exact to='/explore/tags'><WrapFormattedMessage id='explore.trending_tags' defaultMessage='Hashtags' /></NavLink> <FormattedMessage tagName='div' id='explore.trending_statuses' defaultMessage='Posts' />
<NavLink exact to='/explore/links'><WrapFormattedMessage id='explore.trending_links' defaultMessage='News' /></NavLink> </NavLink>
{signedIn && <NavLink exact to='/explore/suggestions'><WrapFormattedMessage id='explore.suggested_follows' defaultMessage='For you' /></NavLink>} <NavLink exact to='/explore/tags'>
<FormattedMessage tagName='div' id='explore.trending_tags' defaultMessage='Hashtags' />
</NavLink>
<NavLink exact to='/explore/links'>
<FormattedMessage tagName='div' id='explore.trending_links' defaultMessage='News' />
</NavLink>
{signedIn && (
<NavLink exact to='/explore/suggestions'>
<FormattedMessage tagName='div' id='explore.suggested_follows' defaultMessage='For you' />
</NavLink>
)}
</div> </div>
<Switch> <Switch>
@ -97,7 +97,7 @@ class Explore extends React.PureComponent {
<title>{intl.formatMessage(messages.title)}</title> <title>{intl.formatMessage(messages.title)}</title>
<meta name='robots' content={isSearching ? 'noindex' : 'all'} /> <meta name='robots' content={isSearching ? 'noindex' : 'all'} />
</Helmet> </Helmet>
</React.Fragment> </>
)} )}
</div> </div>
</Column> </Column>

View file

@ -2014,6 +2014,22 @@
{ {
"defaultMessage": "Search results", "defaultMessage": "Search results",
"id": "explore.search_results" "id": "explore.search_results"
},
{
"defaultMessage": "Posts",
"id": "explore.trending_statuses"
},
{
"defaultMessage": "Hashtags",
"id": "explore.trending_tags"
},
{
"defaultMessage": "News",
"id": "explore.trending_links"
},
{
"defaultMessage": "For you",
"id": "explore.suggested_follows"
} }
], ],
"path": "app/javascript/mastodon/features/explore/index.json" "path": "app/javascript/mastodon/features/explore/index.json"

View file

@ -235,7 +235,11 @@
"errors.unexpected_crash.copy_stacktrace": "Copy stacktrace to clipboard", "errors.unexpected_crash.copy_stacktrace": "Copy stacktrace to clipboard",
"errors.unexpected_crash.report_issue": "Report issue", "errors.unexpected_crash.report_issue": "Report issue",
"explore.search_results": "Search results", "explore.search_results": "Search results",
"explore.suggested_follows": "For you",
"explore.title": "Explore", "explore.title": "Explore",
"explore.trending_links": "News",
"explore.trending_statuses": "Posts",
"explore.trending_tags": "Hashtags",
"filter_modal.added.context_mismatch_explanation": "This filter category does not apply to the context in which you have accessed this post. If you want the post to be filtered in this context too, you will have to edit the filter.", "filter_modal.added.context_mismatch_explanation": "This filter category does not apply to the context in which you have accessed this post. If you want the post to be filtered in this context too, you will have to edit the filter.",
"filter_modal.added.context_mismatch_title": "Context mismatch!", "filter_modal.added.context_mismatch_title": "Context mismatch!",
"filter_modal.added.expired_explanation": "This filter category has expired, you will need to change the expiration date for it to apply.", "filter_modal.added.expired_explanation": "This filter category has expired, you will need to change the expiration date for it to apply.",