Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Added aria-describedby atttribute to avfield to link error messages #260

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/AvField.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ export default class AvField extends Component {
size={size}
disabled={disabled}
readOnly={readOnly}
aria-describedby = {`${id}-error`}
Copy link
Member

Choose a reason for hiding this comment

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

Let's also make this conditional using the same logic for AvFeedback. We don't want to point to an element that doesn't exist.

Also, please remove the spaces around the = to match the other props.

{...attributes}
>
{children}
</AvInput>);

const validation = this.context.FormCtrl.getInputState(this.props.name);

const feedback = validation.errorMessage ? (<AvFeedback>{validation.errorMessage}</AvFeedback>) : null;
const feedback = validation.errorMessage ? (<AvFeedback id={`${id}-error`}>{validation.errorMessage}</AvFeedback>) : null;
const help = helpMessage ? (<FormText>{helpMessage}</FormText>) : null;
const inputRow = row ? <Col {...col}>{input}{feedback}{help}</Col> : input;
const check = attributes.type === 'checkbox';
Expand Down