Skip to content

Commit

Permalink
Make cancel link more accessible (#469)
Browse files Browse the repository at this point in the history
* Make cancel link more accessible

* Fix test markup
  • Loading branch information
RobbieTheWagner authored Jul 30, 2019
1 parent 08788a8 commit 94ba9ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/js/components/shepherd-content/shepherd-header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,14 @@ export default class ShepherdHeader extends Component {

_addCancelLink(showCancelLink, styles) {
if (showCancelLink) {
return <a
href=''
return <button
aria-label='Close Tour'
className={styles['cancel-link'].trim()}
onClick={this.cancelStep}
/>;
type='button'
>
<span aria-hidden='true'>&times;</span>
</button>;
}

return null;
Expand Down
5 changes: 2 additions & 3 deletions src/js/components/shepherd-content/shepherd-header/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { lighten } from 'polished';
export default function headerStyles(classPrefix, variables) {
return {
'cancel-link': {
background: 'transparent',
border: 'none',
color: lighten(0.7, variables.shepherdThemeTextHeader),
fontSize: '2em',
fontWeight: 'normal',
Expand All @@ -15,9 +17,6 @@ export default function headerStyles(classPrefix, variables) {
'&:hover': {
color: variables.shepherdThemeTextHeader,
cursor: 'pointer'
},
'&:before': {
content: '"\u00d7"'
}
},

Expand Down
4 changes: 2 additions & 2 deletions test/unit/components/shepherd-header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('components/ShepherdHeader', () => {
};

const header = <ShepherdHeader step={step} styles={styles}/>;
expect(header).to.include(<a class="shepherd-cancel-link" href=""></a>);
expect(header).to.include(<button aria-label="Close Tour" class="shepherd-cancel-link" type="button"><span aria-hidden="true">×</span></button>);
});

it('cancel link is not added when showCancelLink === false', () => {
Expand All @@ -31,7 +31,7 @@ describe('components/ShepherdHeader', () => {
};

const header = <ShepherdHeader step={step} styles={styles}/>;
expect(header).to.not.include(<a class="shepherd-cancel-link" href=""></a>);
expect(header).to.not.include(<button aria-label="Close Tour" className="shepherd-cancel-link" type="button"><span aria-hidden="true">×</span></button>);
});

it('cancel link cancels the tour', async () => {
Expand Down

0 comments on commit 94ba9ba

Please sign in to comment.