Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(forms): add message id to input aria-describedby attribute #1389

Merged
merged 5 commits into from
Aug 2, 2022

Conversation

Francois-Esquire
Copy link
Contributor

@Francois-Esquire Francois-Esquire commented Jul 29, 2022

Description

This PR adds the Message component ID in the aria-describedby attribute for a given Input (Select, Radio, etc) component within a Field.

Detail

There was an update made to @zendeskgarden/container-field v2.1.0 which associates the Message component ID to the aria-describedby attribute of a given Input when it is present. The aria-describedby attribute is a combination of the Hint and Message component IDs, however the ID of either of those components will not be added if they are not present as children of the Field component.

Cross browser caveats

In Safari (using VoiceOver), a concatenated list of text node IDs are not all read, only the first item is. However, other browsers behave as expected.

Checklist

  • 👌 design updates are Garden Designer approved (add the
    designer as a reviewer)
  • 🌐 demo is up-to-date (yarn start)
  • ⬅️ renders as expected with reversed (RTL) direction
  • 🤘 renders as expected with Bedrock CSS (?bedrock)
  • ♿ analyzed via axe and evaluated using VoiceOver
  • 💂‍♂️ includes new unit tests
  • 📝 tested in Chrome, Firefox, Safari, Edge, and IE11

@@ -42,7 +42,7 @@ export const Input = React.forwardRef<HTMLInputElement, IInputProps>(
}

if (fieldContext) {
combinedProps = fieldContext.getInputProps(combinedProps, { isDescribed: true });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that the isDescribed option is true on multiple input components including Input. I found it was safe to remove after getInputProps was given a default value for the second function parameter. Are there any concerns with removing?

setHint: (hintPresent: boolean) => setHasHint(hintPresent),
hasHint
hasHint,
setHasHint,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setHint was renamed to setHasHint for consistency and clarity in its function, the new setHasMessage also follows this naming pattern.

Copy link
Member

@jzempel jzempel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.

@@ -42,8 +54,8 @@ export const Message = React.forwardRef<HTMLDivElement, IMessageProps>(

let combinedProps = { validation, validationLabel, ...props };

if (fieldContext) {
combinedProps = fieldContext.getMessageProps(combinedProps);
if (typeof getMessageProps === 'function') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems indicative of poor typing within the context, but might not be worth addressing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've cleaned this up and removed the typeof check, I was mistakenly thinking the Field context could be misused (however it is not publicly exported).

@Francois-Esquire Francois-Esquire merged commit 56b157e into main Aug 2, 2022
@Francois-Esquire Francois-Esquire deleted the francois-esquire/fix-message-describedby branch August 2, 2022 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants