Skip to content

Commit

Permalink
feat(Select): add ariaLabel prop
Browse files Browse the repository at this point in the history
  • Loading branch information
sarkaaa committed Dec 10, 2024
1 parent e64f49f commit 1f4fce7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/orbit-components/src/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const Select = React.forwardRef<HTMLSelectElement, Props>((props, ref) => {
customValueText,
insideInputGroup,
dataAttrs,
ariaLabel,
} = props;
const filled = !(value == null || value === "");

Expand Down Expand Up @@ -67,6 +68,7 @@ const Select = React.forwardRef<HTMLSelectElement, Props>((props, ref) => {
className={cx("relative block", spaceAfter && spaceAfterClasses[spaceAfter])}
ref={inputRef}
style={{ width }}
aria-label={label?.toString() || ariaLabel?.toString()}
>
{label && !inlineLabel && (
<FormLabel
Expand Down Expand Up @@ -167,11 +169,11 @@ const Select = React.forwardRef<HTMLSelectElement, Props>((props, ref) => {
onBlur={onBlur}
onChange={onChange}
tabIndex={tabIndex ? Number(tabIndex) : undefined}
id={selectId}
required={required}
ref={ref}
aria-describedby={shown ? `${selectId}-feedback` : undefined}
aria-invalid={error ? true : undefined}
aria-label={ariaLabel}
{...dataAttrs}
>
{placeholder && (
Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/Select/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ export interface Props extends Common.Globals, Common.SpaceAfter, Common.DataAtt
readonly insideInputGroup?: boolean;
readonly inlineLabel?: boolean;
readonly customValueText?: Common.Translation;
readonly ariaLabel?: string;
}

0 comments on commit 1f4fce7

Please sign in to comment.