0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(console): add a11y to the SenderTester (#2636)

This commit is contained in:
Xiao Yijun 2022-12-13 11:42:06 +08:00 committed by GitHub
parent 89651833d2
commit 91b82fef3f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -12,6 +12,7 @@ import FormField from '@/components/FormField';
import TextInput from '@/components/TextInput';
import { Tooltip } from '@/components/Tip';
import useApi from '@/hooks/use-api';
import { onKeyDownHandler } from '@/utilities/a11y';
import { safeParseJson } from '@/utilities/json';
import * as styles from './index.module.scss';
@ -90,6 +91,7 @@ const SenderTester = ({ connectorId, connectorType, config, className }: Props)
? t('connector_details.test_sms_placeholder')
: t('connector_details.test_email_placeholder')
}
onKeyDown={onKeyDownHandler({ Enter: onSubmit })}
{...register('sendTo', {
required: true,
pattern: {

View file

@ -15,7 +15,11 @@ export const onKeyDownHandler =
}
if (typeof callback === 'object') {
callback[key]?.(event);
const handler = callback[key];
if (handler) {
handler(event);
event.preventDefault();
}
}
};