Skip to content

Commit

Permalink
[terra-form-fieldset]fix for aria-labelledby (cerner#3720)
Browse files Browse the repository at this point in the history
* first comit

* Chnagelog

* ChangeLog

* Wdio

* wdio Update

* ChangeLog

* jest Snap Update

* Revert "jest Snap Update"

This reverts commit a64d4bd.
  • Loading branch information
udaymattam authored Feb 14, 2023
1 parent 177f6bf commit ddcaa6b
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/terra-core-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Updated
* Updated jest & wdio tests.

* Added
* Added A11y guide and examples for `terra-button`.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import Field from 'terra-form-field';
import Input from 'terra-form-input';
import Fieldset from 'terra-form-fieldset';

const fieldsetwithouthiddenlegendandhelptext = () => (
<Fieldset
required
isLegendHidden
>
<Field label="First" isInline required htmlFor="first">
<Input id="first" type="text" name="first" defaultValue="" />
</Field>
<Field label="Middle" isInline required htmlFor="middle">
<Input id="middle" type="text" name="middle" defaultValue="" />
</Field>
<Field label="Last" isInline required htmlFor="last">
<Input id="last" type="text" name="last" defaultValue="" />
</Field>
</Fieldset>
);

export default fieldsetwithouthiddenlegendandhelptext;
3 changes: 3 additions & 0 deletions packages/terra-form-fieldset/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Updated
* Fixed jest test failures caused by empty children nodes.

## 2.67.0 - (February 7, 2023)

* Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/terra-form-fieldset/src/Fieldset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const Fieldset = ({
{legend && <legend id={legendId} {...legendAttrs} className={legendClasses}>{legend}</legend>}
{help && <small id={helpId} className={cx('help-text')} tabIndex="-1">{help}</small>}
<div className={cx('fieldset-children')}>
{addAriaHelpers(children)}
{(help || legend) && children ? addAriaHelpers(children) : children}
</div>
</fieldset>
);
Expand Down
15 changes: 15 additions & 0 deletions packages/terra-form-fieldset/tests/jest/FormFieldset.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ it('should render a Fieldset when all the possible props are passed into it', ()
expect(wrapper).toMatchSnapshot();
});

it('should render a Fieldset without legend and helptext', () => {
const input = (
<Fieldset
className="fieldset-custom"
legendAttrs={{ className: 'healtheintent-legend' }}
required
>
<input type="radio" value="Test" />
</Fieldset>
);

const wrapper = shallow(input);
expect(wrapper).toMatchSnapshot();
});

it('correctly applies the theme context className', () => {
const wrapper = mount(
<ThemeContextProvider theme={{ className: 'orion-fusion-theme' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ exports[`should render a Fieldset when all the possible props are passed into it
</fieldset>
`;

exports[`should render a Fieldset without legend and helptext 1`] = `
<fieldset
className="fieldset fieldset-required fieldset-custom"
>
<div
className="fieldset-children"
>
<input
type="radio"
value="Test"
/>
</div>
</fieldset>
`;

exports[`should render a default component 1`] = `
<fieldset
className="fieldset"
Expand Down
6 changes: 6 additions & 0 deletions packages/terra-form-fieldset/tests/wdio/fieldset-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ Terra.describeViewports('Fieldset', ['tiny', 'medium'], () => {

Terra.validates.element('populated Fieldset with hidden legend');
});

it('should display populated Fieldset without legend and helptext', () => {
browser.url('/raw/tests/cerner-terra-core-docs/form-fieldset/fieldset-without-legend-and-helptext');

Terra.validates.accessibility();
});
});

0 comments on commit ddcaa6b

Please sign in to comment.