Auto-focus mobile composer (#39360)
This commit is contained in:
parent
40bf2dca1e
commit
782ceb3795
@ -193,7 +193,11 @@ const Compose: React.FC<{ multiColumn: boolean }> = ({ multiColumn }) => {
|
||||
/>
|
||||
|
||||
<div className='scrollable'>
|
||||
<ComposeFormContainer />
|
||||
<ComposeFormContainer
|
||||
// This is fine on this single-purpose view
|
||||
// eslint-disable-next-line jsx-a11y/no-autofocus
|
||||
autoFocus
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Helmet>
|
||||
|
||||
@ -263,7 +263,7 @@ export const NavigationPanel: React.FC<{ multiColumn?: boolean }> = ({
|
||||
{!multiColumn && (
|
||||
<li>
|
||||
<ColumnLink
|
||||
to='/publish'
|
||||
to={{ pathname: '/publish', state: { focusTarget: false } }}
|
||||
icon='plus'
|
||||
iconComponent={AddIcon}
|
||||
activeIconComponent={AddIcon}
|
||||
|
||||
@ -3,6 +3,7 @@ import { useRouteMatch, NavLink } from 'react-router-dom';
|
||||
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
import type { IconProp } from 'mastodon/components/icon';
|
||||
import type { MastodonLocationDescriptor } from 'mastodon/components/router';
|
||||
|
||||
export const ColumnLink: React.FC<{
|
||||
icon: React.ReactNode;
|
||||
@ -11,7 +12,7 @@ export const ColumnLink: React.FC<{
|
||||
activeIconComponent?: IconProp;
|
||||
isActive?: (match: unknown, location: { pathname: string }) => boolean;
|
||||
text: string;
|
||||
to?: string;
|
||||
to?: MastodonLocationDescriptor;
|
||||
href?: string;
|
||||
method?: string;
|
||||
badge?: React.ReactNode;
|
||||
@ -31,7 +32,9 @@ export const ColumnLink: React.FC<{
|
||||
transparent,
|
||||
...other
|
||||
}) => {
|
||||
const match = useRouteMatch(to ?? '');
|
||||
const match = useRouteMatch(
|
||||
(typeof to === 'string' ? to : to?.pathname) ?? '',
|
||||
);
|
||||
const className = classNames('column-link', {
|
||||
'column-link--transparent': transparent,
|
||||
});
|
||||
|
||||
@ -17,6 +17,7 @@ import { toggleNavigation } from 'mastodon/actions/navigation';
|
||||
import { fetchServer } from 'mastodon/actions/server';
|
||||
import { Icon } from 'mastodon/components/icon';
|
||||
import { IconWithBadge } from 'mastodon/components/icon_with_badge';
|
||||
import type { MastodonLocationDescriptor } from 'mastodon/components/router';
|
||||
import { useIdentity } from 'mastodon/identity_context';
|
||||
import { registrationsOpen, sso_redirect } from 'mastodon/initial_state';
|
||||
import { selectUnreadNotificationGroupsCount } from 'mastodon/selectors/notifications';
|
||||
@ -38,12 +39,14 @@ export const messages = defineMessages({
|
||||
});
|
||||
|
||||
const IconLabelButton: React.FC<{
|
||||
to: string;
|
||||
to: MastodonLocationDescriptor;
|
||||
icon?: React.ReactNode;
|
||||
activeIcon?: React.ReactNode;
|
||||
title: string;
|
||||
}> = ({ to, icon, activeIcon, title }) => {
|
||||
const match = useRouteMatch(to);
|
||||
const match = useRouteMatch(
|
||||
typeof to === 'string' ? to : (to.pathname ?? ''),
|
||||
);
|
||||
|
||||
return (
|
||||
<NavLink
|
||||
@ -189,7 +192,7 @@ export const NavigationBar: React.FC = () => {
|
||||
/>
|
||||
<IconLabelButton
|
||||
title={intl.formatMessage(messages.publish)}
|
||||
to='/publish'
|
||||
to={{ pathname: '/publish', state: { focusTarget: false } }}
|
||||
icon={<Icon id='' icon={AddIcon} />}
|
||||
/>
|
||||
<NotificationsButton />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user