Skip to content

Commit cef47ec

Browse files
authored
Add ariaLabel to TextField for accessibility (#3387)
* Add ariaLabel to TextField for accessibility * Refactor label handling in InputDialogItem component
1 parent e610bdb commit cef47ec

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

packages/roosterjs-react/lib/inputDialog/component/InputDialogItem.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function InputDialogItem<Strings extends string, ItemNames extends string
3737
const { itemName, strings, items, currentValues, onChanged, onEnterKey, rows } = props;
3838
const { labelKey, unlocalizedLabel, autoFocus } = items[itemName];
3939
const value = currentValues[itemName];
40+
const label = labelKey ? getLocalizedString(strings, labelKey, unlocalizedLabel) : undefined;
4041
const onValueChange = React.useCallback(
4142
(_, newValue) => {
4243
onChanged(itemName, newValue);
@@ -55,11 +56,12 @@ export function InputDialogItem<Strings extends string, ItemNames extends string
5556

5657
return (
5758
<div>
58-
{labelKey ? <div>{getLocalizedString(strings, labelKey, unlocalizedLabel)}</div> : null}
59+
{label ? <div>{label}</div> : null}
5960
<div>
6061
<TextField
6162
role="textbox"
6263
type="text"
64+
ariaLabel={label}
6365
className={classNames.inputBox}
6466
value={value}
6567
onChange={onValueChange}

0 commit comments

Comments
 (0)