[Glitch] Auto-focus mobile composer

Port 782ceb3795e3cc97cb0e7e29983962adcea7e946 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
diondiondion 2026-06-11 10:15:40 +02:00 committed by Claire
parent e5cf23b3b5
commit 704e570dfb
4 changed files with 17 additions and 7 deletions

View File

@ -249,7 +249,11 @@ const Compose: React.FC<{ multiColumn: boolean }> = ({ multiColumn }) => {
/> />
<div className='scrollable'> <div className='scrollable'>
<ComposeFormContainer /> <ComposeFormContainer
// This is fine on this single-purpose view
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus
/>
</div> </div>
<Helmet> <Helmet>

View File

@ -285,7 +285,7 @@ export const NavigationPanel: React.FC<{ multiColumn?: boolean }> = ({
{!multiColumn && ( {!multiColumn && (
<li> <li>
<ColumnLink <ColumnLink
to='/publish' to={{ pathname: '/publish', state: { focusTarget: false } }}
icon='plus' icon='plus'
iconComponent={AddIcon} iconComponent={AddIcon}
activeIconComponent={AddIcon} activeIconComponent={AddIcon}

View File

@ -5,6 +5,7 @@ import { useRouteMatch, NavLink } from 'react-router-dom';
import { Icon } from 'flavours/glitch/components/icon'; import { Icon } from 'flavours/glitch/components/icon';
import type { IconProp } from 'flavours/glitch/components/icon'; import type { IconProp } from 'flavours/glitch/components/icon';
import type { MastodonLocationDescriptor } from 'flavours/glitch/components/router';
export const ColumnLink: React.FC<{ export const ColumnLink: React.FC<{
icon: React.ReactNode; icon: React.ReactNode;
@ -13,7 +14,7 @@ export const ColumnLink: React.FC<{
activeIconComponent?: IconProp; activeIconComponent?: IconProp;
isActive?: (match: unknown, location: { pathname: string }) => boolean; isActive?: (match: unknown, location: { pathname: string }) => boolean;
text: string; text: string;
to?: string; to?: MastodonLocationDescriptor;
onClick?: MouseEventHandler; onClick?: MouseEventHandler;
href?: string; href?: string;
method?: string; method?: string;
@ -35,7 +36,9 @@ export const ColumnLink: React.FC<{
transparent, transparent,
...other ...other
}) => { }) => {
const match = useRouteMatch(to ?? ''); const match = useRouteMatch(
(typeof to === 'string' ? to : to?.pathname) ?? '',
);
const className = classNames('column-link', { const className = classNames('column-link', {
'column-link--transparent': transparent, 'column-link--transparent': transparent,
}); });

View File

@ -17,6 +17,7 @@ import { toggleNavigation } from 'flavours/glitch/actions/navigation';
import { fetchServer } from 'flavours/glitch/actions/server'; import { fetchServer } from 'flavours/glitch/actions/server';
import { Icon } from 'flavours/glitch/components/icon'; import { Icon } from 'flavours/glitch/components/icon';
import { IconWithBadge } from 'flavours/glitch/components/icon_with_badge'; import { IconWithBadge } from 'flavours/glitch/components/icon_with_badge';
import type { MastodonLocationDescriptor } from 'flavours/glitch/components/router';
import { useIdentity } from 'flavours/glitch/identity_context'; import { useIdentity } from 'flavours/glitch/identity_context';
import { registrationsOpen, sso_redirect } from 'flavours/glitch/initial_state'; import { registrationsOpen, sso_redirect } from 'flavours/glitch/initial_state';
import { selectUnreadNotificationGroupsCount } from 'flavours/glitch/selectors/notifications'; import { selectUnreadNotificationGroupsCount } from 'flavours/glitch/selectors/notifications';
@ -38,12 +39,14 @@ export const messages = defineMessages({
}); });
const IconLabelButton: React.FC<{ const IconLabelButton: React.FC<{
to: string; to: MastodonLocationDescriptor;
icon?: React.ReactNode; icon?: React.ReactNode;
activeIcon?: React.ReactNode; activeIcon?: React.ReactNode;
title: string; title: string;
}> = ({ to, icon, activeIcon, title }) => { }> = ({ to, icon, activeIcon, title }) => {
const match = useRouteMatch(to); const match = useRouteMatch(
typeof to === 'string' ? to : (to.pathname ?? ''),
);
return ( return (
<NavLink <NavLink
@ -189,7 +192,7 @@ export const NavigationBar: React.FC = () => {
/> />
<IconLabelButton <IconLabelButton
title={intl.formatMessage(messages.publish)} title={intl.formatMessage(messages.publish)}
to='/publish' to={{ pathname: '/publish', state: { focusTarget: false } }}
icon={<Icon id='' icon={AddIcon} />} icon={<Icon id='' icon={AddIcon} />}
/> />
<NotificationsButton /> <NotificationsButton />