Skip to content

Commit

Permalink
fix(#4317): LabeledValue: ContextualHelp button should be labeled by …
Browse files Browse the repository at this point in the history
…the label (#4319)
  • Loading branch information
majornista authored May 26, 2023
1 parent 05f36e6 commit 5c64bcb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/@react-spectrum/label/src/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Field(props: SpectrumFieldProps, ref: RefObject<HTMLElement>) {
showErrorIcon,
contextualHelp,
children,
labelProps,
labelProps = {},
// Not every component that uses <Field> supports help text.
descriptionProps = {},
errorMessageProps = {},
Expand All @@ -52,6 +52,11 @@ function Field(props: SpectrumFieldProps, ref: RefObject<HTMLElement>) {
let hasHelpText = !!description || errorMessage && validationState === 'invalid';
let contextualHelpId = useId();

let fallbackLabelPropsId = useId();
if (label && contextualHelp && !labelProps.id) {
labelProps.id = fallbackLabelPropsId;
}

let labelWrapperClass = classNames(
labelStyles,
'spectrum-Field',
Expand Down

0 comments on commit 5c64bcb

Please sign in to comment.