Skip to content

Commit

Permalink
feat: change order
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmch committed Aug 22, 2023
1 parent eb27c04 commit b2162de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/components/controls/TextInput/TextInputControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ export function TextInputControl(props: Props) {
const describedBy = React.useMemo(() => {
const result = [];
if (id) {
if (error) {
result.push(getControlErrorTextId(id));
}
if (note) {
result.push(getControlNoteId(id));
}

if (error) {
result.push(getControlErrorTextId(id));
}
}
return result.join(' ');
}, [error, note, id]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe('TextInput input', () => {
const noteTextElement = container.querySelector(`#${getControlNoteId(inputId)}`);

expect(input.getAttribute('aria-describedby')).toBe(
`${getControlErrorTextId(inputId)} ${getControlNoteId(inputId)}`,
`${getControlNoteId(inputId)} ${getControlErrorTextId(inputId)}`,
);
expect(errorTextElement?.textContent).toBe(errorText);
expect(noteTextElement?.textContent).toBe(noteText);
Expand Down

0 comments on commit b2162de

Please sign in to comment.