Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instant Search: improve accessibility of close button #17294

Merged
merged 6 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 8 additions & 1 deletion modules/search/instant-search/components/gridicon/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import { __ } from '@wordpress/i18n';
import './style.scss';

class Gridicon extends Component {
static defaultProps = {
'aria-hidden': 'false',
focusable: 'true',
};

needsOffset( icon, size ) {
const iconNeedsOffset = [
'gridicons-calendar',
Expand Down Expand Up @@ -46,7 +51,7 @@ class Gridicon extends Component {
case 'gridicons-comment':
return <title>{ __( 'Matching comment.', 'jetpack' ) }</title>;
case 'gridicons-cross':
return <title>{ __( 'Close search overlay', 'jetpack' ) }</title>;
return <title>{ __( 'Close search results', 'jetpack' ) }</title>;
case 'gridicons-filter':
return <title>{ __( 'Toggle search filters.', 'jetpack' ) }</title>;
case 'gridicons-folder':
Expand Down Expand Up @@ -193,12 +198,14 @@ class Gridicon extends Component {
return (
<svg
className={ iconClass }
focusable={ this.props.focusable }
height={ size }
onClick={ this.props.onClick }
style={ { height: size, width: size } }
viewBox="0 0 24 24"
width={ size }
xmlns="http://www.w3.org/2000/svg"
aria-hidden={ this.props[ 'aria-hidden' ] }
>
{ this.getSVGTitle( icon ) }
{ this.renderIcon( icon ) }
Expand Down
27 changes: 1 addition & 26 deletions modules/search/instant-search/components/overlay.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$overlay-vertical-padding: 3.5em;
$overlay-vertical-padding: 4em;
bluefuton marked this conversation as resolved.
Show resolved Hide resolved
$overlay-horizontal-padding: 1em;
$overlay-horizontal-padding-small-viewport: 0.5em;

Expand Down Expand Up @@ -38,28 +38,3 @@ $overlay-horizontal-padding-small-viewport: 0.5em;
box-sizing: inherit;
}
}

.jetpack-instant-search__overlay-close {
display: flex;
align-items: center;
justify-content: center;
position: fixed;
top: 0;
right: 0;
z-index: 20;
width: 40px;
height: 40px;
margin: 0;
padding: 0;
line-height: 1;
cursor: pointer;

@include break-medium() {
position: absolute;
top: -$overlay-vertical-padding;
right: 8px;
width: 64px;
height: 64px;
padding: 20px;
}
}
8 changes: 4 additions & 4 deletions modules/search/instant-search/components/search-results.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ class SearchResults extends Component {
aria-live="polite"
className="jetpack-instant-search__search-results"
>
<a
<button
bluefuton marked this conversation as resolved.
Show resolved Hide resolved
className="jetpack-instant-search__overlay-close"
onClick={ this.closeOverlay }
onKeyPress={ this.onKeyPressHandler }
role="button"
tabIndex="0"
aria-label={ __( 'Close search results', 'jetpack' ) }
bluefuton marked this conversation as resolved.
Show resolved Hide resolved
>
<Gridicon icon="cross" size="24" />
</a>
<Gridicon icon="cross" size="24" aria-hidden="true" focusable="false" />
</button>
<div className="jetpack-instant-search__search-results-primary">
{ this.renderPrimarySection() }
</div>
Expand Down
41 changes: 41 additions & 0 deletions modules/search/instant-search/components/search-results.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
.jetpack-instant-search__overlay-close svg {
fill: #000;
}

.jetpack-instant-search__overlay-close:focus {
outline-color: #000;
}
}

.jetpack-instant-search__overlay--dark & {
Expand All @@ -34,6 +38,10 @@
.jetpack-instant-search__overlay-close svg {
fill: #fff;
}

.jetpack-instant-search__overlay-close:focus {
outline-color: #fff;
}
}

@include break-small() {
Expand Down Expand Up @@ -121,3 +129,36 @@
font-size: 0.9em;
}
}

.jetpack-instant-search__overlay-close {
appearance: none;
background: none;
border: none;
display: flex;
align-items: center;
justify-content: center;
position: fixed;
top: 0;
right: 0;
z-index: 20;
width: 40px;
height: 40px;
margin: 0;
padding: 0;
line-height: 1;
cursor: pointer;
text-decoration: none;

@include break-medium() {
position: absolute;
top: -$overlay-vertical-padding;
right: 8px;
width: 64px;
height: 64px;
padding: 20px;
}

&:focus {
outline: 1px dotted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ exports[`returns a notice if the type is warning 1`] = `
class="jetpack-instant-search__notice jetpack-instant-search__notice--warning"
>
<svg
aria-hidden="false"
class="gridicon gridicons-info "
focusable="true"
height="20"
style="height: 20px; width: 20px;"
viewBox="0 0 24 24"
Expand Down