Skip to content

Commit

Permalink
WIP accessibility on tabs and filters
Browse files Browse the repository at this point in the history
  • Loading branch information
kreafox committed Apr 4, 2023
1 parent 9a740e8 commit bc2d6ec
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 6 deletions.
11 changes: 11 additions & 0 deletions searchlib/components/Facets/ActiveFilters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ const ActiveFilters = (props) => {
onRemove([activeFilter || '']);
}
}}
onKeyDown={(e) => {
if (e.key === 'Enter') {
if (Array.isArray(activeFilter)) {
(activeFilter || []).forEach((v) => {
onRemove(v);
});
} else {
onRemove([activeFilter || '']);
}
}
}}
/>
</div>
) : null;
Expand Down
14 changes: 13 additions & 1 deletion searchlib/components/Facets/Connected/SectionTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,32 @@ const SectionTabs = (props) => {
<Ref innerRef={menuRef}>
<Menu secondary pointing className="content-section-tabs">
<Menu.Item
tabIndex={0}
active={activeValues.length === 0}
onClick={() => {
searchContext.removeFilter(facetField, '', 'any');
}}
active={activeValues.length === 0}
onKeyDown={(e) => {
if (e.key === 'Enter') {
searchContext.removeFilter(facetField, '', 'any');
}
}}
>
{`All (${allCount})`}
</Menu.Item>
{sections.map(({ value, count }) => (
<Menu.Item
key={value}
tabIndex={0}
active={activeValues.includes(value)}
onClick={() => {
searchContext.setFilter(facetField, value, 'any');
}}
onKeyDown={(e) => {
if (e.key === 'Enter') {
searchContext.setFilter(facetField, value, 'any');
}
}}
>
{/*<Icon type={value} family="Content types" />*/}
<span className="title">{value}</span>
Expand Down
5 changes: 5 additions & 0 deletions searchlib/components/Facets/DropdownFacetsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ const DropdownFacetsList = ({ defaultWrapper }) => {
<Button
className="sui-button basic"
onClick={() => setShowSidebar(true)}
onKeyDown={(e) => {
if (e.key === 'Enter') {
setShowSidebar(true);
}
}}
// disabled={isLiveSearch}
>
+ More filters
Expand Down
10 changes: 10 additions & 0 deletions searchlib/components/Facets/ModalFacetsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ const FacetsList = ({ view, defaultWrapper }) => {
// clearFilters(exclude);
// setVisibleFacets(alwaysVisibleFacets);
}}
onKeyDown={(e) => {
if (e.key === 'Enter') {
searchContext.resetFilters();
}
}}
/>
</div>

Expand Down Expand Up @@ -128,6 +133,11 @@ const FacetsList = ({ view, defaultWrapper }) => {
onClick={() => {
setSelectFilters(alwaysVisibleFacets);
}}
onKeyDown={(e) => {
if (e.key === 'Enter') {
setSelectFilters(alwaysVisibleFacets);
}
}}
/>
</h5>
<div className="facets-wrapper">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ const ActiveFilters = (props) => {
}
setActiveFilter([]);
}}
onKeyDown={(e) => {
if (e.key === 'Enter') {
if (state.length > 0) {
dispatch({
type: 'reset',
value: [],
id: 'btn-clear-filters',
});
}
setActiveFilter([]);
}
}}
/>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ const DropdownFacetWrapper = (props) => {
<Dropdown
open={isOpen}
onClick={() => setIsOpen(true)}
onKeyDown={(e) => {
if (e.key === 'Enter') {
setIsOpen(true);
}
}}
trigger={
<span className="facet-title">
<span className="facet-title" tabIndex={0} role="button">
{label ? <>{label} </> : <>{title} </>}
{filtersCount.length > 0 && (
<span className="count">({filtersCount})</span>
Expand Down
5 changes: 5 additions & 0 deletions searchlib/components/FilterList/ActiveFilterList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ const ActiveFilterList = (props) => {
size="mini"
className="clear-btn"
onClick={() => clearFilters()}
onKeyDown={(e) => {
if (e.key === 'Enter') {
clearFilters();
}
}}
>
clear all
</Button>
Expand Down
4 changes: 2 additions & 2 deletions searchlib/components/Filters/DropdownFixedRangeFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ const ViewComponent = (props) => {
<Dropdown
icon="chevron down"
trigger={
<>
<span tabIndex={0} role="button">
{labelText} <span>{value}</span>
</>
</span>
}
inline
options={options}
Expand Down
4 changes: 2 additions & 2 deletions searchlib/components/Sorting/SortingDropdownWithLabel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const SortingViewComponent = (props) => {
<Dropdown
icon="chevron down"
trigger={
<>
<span tabIndex={0} role="button">
{label ? `${label}: ` : ''}
<span>{`${activeLabel}`}</span>
</>
</span>
}
inline
value={activeValue}
Expand Down
1 change: 1 addition & 0 deletions src/SearchBlock/less/dropdown-filterlist.less
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

.ui.dropdown {
position: relative;
margin-right: 5px;

.menu > * {
white-space: normal;
Expand Down
2 changes: 2 additions & 0 deletions src/SearchBlock/less/searchview.less
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ body.searchlib-page {
}

.ui.secondary.pointing.content-section-tabs.menu {
padding-top: 0.2rem;
padding-left: 0.2rem;
overflow-x: auto;

&::-webkit-scrollbar {
Expand Down

0 comments on commit bc2d6ec

Please sign in to comment.