fix(frontend): make the panel usable with screen readers (#6907)

* fix(frontend): make the panel usable with screen readers

* fix(frontend): keep mobile tab names and the inbound expiry hint

Review of #6907 found two gaps in the screen-reader pass:

- On phone-width screens catTabLabel renders only the icon and names the
  tab by putting aria-label on it, but callers now pass that icon with
  aria-hidden for the desktop label, so every Settings, Xray and Host
  category tab lost its name under TalkBack. catTabLabel now clears
  aria-hidden on the icon it uses as the name.
- DateTimePicker forwarded id and aria-label but not aria-describedby,
  so the inbound expiry hint ("leave blank to never expire") was never
  attached. It now forwards it on both the Gregorian and Jalali input.
This commit is contained in:
Alireza Ahmadi
2026-10-23 18:29:47 +02:00
committed by GitHub
parent 775b2b0b26
commit e2184777a0
156 changed files with 2373 additions and 863 deletions
@@ -1,6 +1,6 @@
import type { ReactNode } from 'react';
import { useId, type ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, Form, Input, InputNumber, Select, Space, Switch, Tooltip } from 'antd';
import { Button, Form, Input, InputNumber, Select, Space, Switch } from 'antd';
import { MinusOutlined, PlusOutlined } from '@ant-design/icons';
import { useFieldArray, useFormContext } from 'react-hook-form';
@@ -9,28 +9,39 @@ import { FormField } from '@/components/form/rhf';
interface StringListProps {
name: string[];
label: ReactNode;
tooltip?: string;
placeholder: (index: number) => string;
}
function StringList({ name, label, placeholder }: StringListProps) {
function StringList({ name, label, tooltip, placeholder }: StringListProps) {
const { t } = useTranslation();
const labelId = useId();
const { control } = useFormContext();
const { fields, append, remove } = useFieldArray({ control, name: name.join('.') });
return (
<Form.Item label={label}>
<Form.Item label={<span id={labelId}>{label}</span>} tooltip={tooltip}>
<Button aria-label={t('add')} size="small" onClick={() => append('')}>
<PlusOutlined />
<PlusOutlined aria-hidden />
</Button>
{fields.map((field, j) => (
<Space.Compact key={field.id} block className="mt-4">
<FormField name={[...name, j]} noStyle>
<Input placeholder={placeholder(j)} />
<Input
aria-labelledby={labelId}
aria-describedby={tooltip ? `${labelId}-hint` : undefined}
placeholder={placeholder(j)}
/>
</FormField>
<Button aria-label={t('remove')} size="small" onClick={() => remove(j)}>
<MinusOutlined />
<MinusOutlined aria-hidden />
</Button>
</Space.Compact>
))}
{tooltip && (
<span id={`${labelId}-hint`} hidden>
{tooltip}
</span>
)}
</Form.Item>
);
}
@@ -73,20 +84,14 @@ export default function TunFields() {
</FormField>
<StringList
name={['settings', 'autoSystemRoutingTable']}
label={
<Tooltip title={t('pages.inbounds.form.autoSystemRoutesTooltip')}>
{t('pages.inbounds.info.autoSystemRoutes')}
</Tooltip>
}
label={t('pages.inbounds.info.autoSystemRoutes')}
tooltip={t('pages.inbounds.form.autoSystemRoutesTooltip')}
placeholder={(j) => (j === 0 ? '0.0.0.0/0' : '::/0')}
/>
<FormField
name={['settings', 'autoOutboundsInterface']}
label={
<Tooltip title={t('pages.inbounds.form.autoOutboundsInterfaceTooltip')}>
{t('pages.inbounds.form.autoOutboundsInterface')}
</Tooltip>
}
label={t('pages.inbounds.form.autoOutboundsInterface')}
tooltip={t('pages.inbounds.form.autoOutboundsInterfaceTooltip')}
>
<Input placeholder="auto" />
</FormField>