Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(input): add accessibility label and keypress handler to clear input (#15813)

Joshua Irmera18888973536
diff --git a/lang/main-de.json b/lang/main-de.json
index e1e38fb207..7ced83f6e9 100644
--- a/lang/main-de.json
+++ b/lang/main-de.json
@@ -673,6 +673,9 @@
"support": "Support",
"supportMsg": "Wenn der Fehler erneut auftritt, bitte kontaktieren Sie"
},
+ "inputAction": {
+ "deleteInput": "Eingabe läschen"
+ },
"inviteDialog": {
"alertText": "Die Einladung einiger Personen ist fehlgeschlagen.",
"header": "Einladen",
diff --git a/lang/main.json b/lang/main.json
index e0bde2de7f..39063f8ae0 100644
--- a/lang/main.json
+++ b/lang/main.json
@@ -673,6 +673,9 @@
"support": "Support",
"supportMsg": "If this keeps happening, reach out to"
},
+ "inputAction": {
+ "deleteInput": "Clear input"
+ },
"inviteDialog": {
"alertText": "Failed to invite some participants.",
"header": "Invite",
diff --git a/react/features/base/ui/components/web/Input.tsx b/react/features/base/ui/components/web/Input.tsx
index ff6d6c9aa7..e9a8841b59 100644
--- a/react/features/base/ui/components/web/Input.tsx
+++ b/react/features/base/ui/components/web/Input.tsx
@@ -1,4 +1,5 @@
import React, { useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
import TextareaAutosize from 'react-textarea-autosize';
import { makeStyles } from 'tss-react/mui';
@@ -194,6 +195,7 @@ const Input = React.forwardRef<any, IProps>(({
value
}: IProps, ref) => {
const { classes: styles, cx } = useStyles();
+ const { t } = useTranslation();
const isMobile = isMobileBrowser();
const showClearIcon = clearable && value !== '' && !disabled;
const inputAutoCompleteOff = autoComplete === 'off' ? { 'data-1p-ignore': '' } : {};
@@ -225,6 +227,13 @@ const Input = React.forwardRef<any, IProps>(({
ariaInvalid = undefined;
}
+ const onKeyDownClearInput = useCallback((e: React.KeyboardEvent<HTMLButtonElement>) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ clearInput();
+ }
+ }, [ clearInput ]);
+
return (
<div className = { cx(styles.inputContainer, className) }>
{label && <label
@@ -290,9 +299,12 @@ const Input = React.forwardRef<any, IProps>(({
type = { type }
value = { value } />
)}
- {showClearIcon && <button className = { styles.clearButton }>
+ {showClearIcon && <button
+ aria-label = { t('inputAction.deleteInput') }
+ className = { styles.clearButton }
+ onClick = { clearInput }
+ onKeyDown = { onKeyDownClearInput }>
<Icon
- onClick = { clearInput }
size = { 20 }
src = { IconCloseCircle } />
</button>}