Add aria-label to all <Select /> instances

This commit is contained in:
Josh Perez 2022-04-07 17:40:57 -04:00 committed by GitHub
parent 9ffcd44e6d
commit b96b02593b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 112 additions and 17 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2021 Signal Messenger, LLC
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ChangeEvent } from 'react';
@ -12,7 +12,9 @@ export type Option = Readonly<{
}>;
export type PropsType = Readonly<{
ariaLabel?: string;
disabled?: boolean;
id?: string;
moduleClassName?: string;
name?: string;
options: ReadonlyArray<Option>;
@ -22,7 +24,16 @@ export type PropsType = Readonly<{
export const Select = React.forwardRef(
(
{ disabled, moduleClassName, name, onChange, options, value }: PropsType,
{
ariaLabel,
disabled,
id,
moduleClassName,
name,
onChange,
options,
value,
}: PropsType,
ref: React.Ref<HTMLSelectElement>
): JSX.Element => {
const onSelectChange = (event: ChangeEvent<HTMLSelectElement>) => {
@ -32,7 +43,9 @@ export const Select = React.forwardRef(
return (
<div className={classNames(['module-select', moduleClassName])}>
<select
aria-label={ariaLabel}
disabled={disabled}
id={id}
name={name}
value={value}
onChange={onSelectChange}