Skip to content

Commit

Permalink
Add aria-expand attribute to Popover (#8)
Browse files Browse the repository at this point in the history
Co-authored-by: Ray Lee <[email protected]>
  • Loading branch information
mikejritter and Ray Lee authored Apr 24, 2024
1 parent 3b16a0c commit f8160fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/Popover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,14 @@ export default class Popover extends Component {
header,
} = this.props;

const {
open,
} = this.state;

return (
<button
type="button"
aria-expanded={open}
onClick={this.handleHeaderClick}
onKeyDown={this.handleHeaderKeyDown}
onMouseEnter={this.handleHeaderMouseEnter}
Expand Down
2 changes: 2 additions & 0 deletions test/specs/components/Popover.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('Popover', () => {
);

this.container.querySelector('button').textContent.should.equal('Header');
this.container.querySelector('button').ariaExpanded.should.equal('false');
});

it('should open when mouse enters the header', function test() {
Expand All @@ -66,6 +67,7 @@ describe('Popover', () => {
return new Promise((resolve) => {
window.setTimeout(() => {
this.container.querySelectorAll('span').length.should.equal(2);
this.container.querySelector('button').ariaExpanded.should.equal('true');
resolve();
}, 1000);
});
Expand Down

0 comments on commit f8160fa

Please sign in to comment.