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

Release: v4.0.8 #373

Merged
merged 2 commits into from
Aug 30, 2023
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
File renamed without changes.
2 changes: 2 additions & 0 deletions src/components/composite/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ class Accordion extends React.Component {
{props.blok.accordionItems.length > 1 && (
<>
<button
type="button"
className={`su-accordion__collapse-all su-button ${accordionButtonColor}`}
onClick={this.collapseAll}
>
Collapse all
</button>
<button
type="button"
className={`su-accordion__expand-all su-button ${accordionButtonColor}`}
onClick={this.expandAll}
>
Expand Down
1 change: 1 addition & 0 deletions src/components/composite/accordionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class AccordionItem extends React.Component {
{...(props.blok.id ? { id: props.blok.id } : {})}
>
<button
type="button"
className={`su-accordion__button ${props.accordionAfterColor} su-${props.accordionFontWeight}`}
aria-expanded={this.state.expanded}
onClick={this.toggle}
Expand Down
1 change: 1 addition & 0 deletions src/components/composite/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export const Modal = ({
>
<div className="su-modal--header">
<button
type="button"
ref={closeButton}
className="su-modal--close"
onClick={onClose}
Expand Down
17 changes: 13 additions & 4 deletions src/components/composite/oodGallerySlideshow.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const oodGallerySlideshow = ({ blok }) => {
{blok.showExpandLink && (
<div className="gallery-slideshow--expand">
<button
type="button"
onClick={openModal}
className="gallery-slideshow--expand-btn"
aria-label="Expand gallery"
Expand All @@ -57,7 +58,11 @@ const oodGallerySlideshow = ({ blok }) => {
</div>

<div className="gallery-slideshow--controls">
<button className="gallery-slideshow--prev" onClick={clickPrev}>
<button
type="button"
className="gallery-slideshow--prev"
onClick={clickPrev}
>
<span className="sr-only">Previous Slide</span>
<i className="fas fa-chevron-left" aria-hidden="true"></i>
</button>
Expand All @@ -75,7 +80,11 @@ const oodGallerySlideshow = ({ blok }) => {
{dots}
</ul>
</div>
<button className="gallery-slideshow--next" onClick={clickNext}>
<button
type="button"
className="gallery-slideshow--next"
onClick={clickNext}
>
<span className="sr-only">Next Slide</span>
<i className="fas fa-chevron-right" aria-hidden="true"></i>
</button>
Expand Down Expand Up @@ -109,13 +118,13 @@ const oodGallerySlideshow = ({ blok }) => {

const modalSliderSettings = {
nextArrow: (
<button>
<button type="button">
<span className="sr-only">Next Slide</span>
<i className="fas fa-chevron-right" aria-hidden="true"></i>
</button>
),
prevArrow: (
<button>
<button type="button">
<span className="sr-only">Previous Slide</span>
<i className="fas fa-chevron-left" aria-hidden="true"></i>
</button>
Expand Down
4 changes: 2 additions & 2 deletions src/components/composite/oodQuoteSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const OodQuoteSlider = ({ blok }) => {

const sliderSettings = {
nextArrow: (
<button>
<button type="button">
<span className="sr-only">
Next Slide:{' '}
{`${
Expand All @@ -22,7 +22,7 @@ const OodQuoteSlider = ({ blok }) => {
</button>
),
prevArrow: (
<button>
<button type="button">
<span className="sr-only">
Previous Slide:{' '}
{`${activeSlide === 0 ? blok.quotes.length : activeSlide} of ${
Expand Down
1 change: 1 addition & 0 deletions src/components/navigation/contentMenu/oodContentMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const OodContentMenu = (props) => {
ref={ref}
>
<button
type="button"
className={`ood-content-nav__toggle`}
aria-expanded={menuOpened}
onClick={toggleMenu}
Expand Down
1 change: 1 addition & 0 deletions src/components/navigation/megaMenu/oodMegaMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const OodMegaMenu = (props) => {
<SbEditable content={props.blok}>
<nav className="ood-mega-nav" aria-label="Main Menu" ref={ref}>
<button
type="button"
className="ood-mega-nav__toggle su-mr-none su-ml-auto"
aria-label={menuOpened ? 'Close Menu' : 'Open Menu'}
aria-expanded={menuOpened}
Expand Down
1 change: 1 addition & 0 deletions src/components/navigation/megaMenu/oodMegaMenuSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const OodMegaMenuSection = (props) => {
<SbEditable content={props.blok}>
<li className="ood-mega-nav__item--parent" ref={ref}>
<button
type="button"
className="ood-mega-nav__trigger"
aria-expanded={sectionOpened}
onClick={toggleSection}
Expand Down
27 changes: 22 additions & 5 deletions src/components/search/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import qs from 'query-string';

/* eslint-disable-next-line react/display-name */
const Autocomplete = React.forwardRef((props, ref) => {
const { inputId, listboxId, ...otherProps } = props;
const [initialTerm, setInitialTerm] = useState('');

const { search } = useLocation();
Expand Down Expand Up @@ -48,11 +49,16 @@ const Autocomplete = React.forwardRef((props, ref) => {
}
};

const containerProps = {
'aria-owns': listboxId,
};

const inputProps = {
ref,
value,
type: 'text',
placeholder: 'Search',
id: inputId,
onChange,
onKeyDown,
onFocus: () => setShouldRenderSuggestions(true),
Expand Down Expand Up @@ -94,17 +100,31 @@ const Autocomplete = React.forwardRef((props, ref) => {

return (
<form role="search" className="search-input">
<label htmlFor={inputId} className="su-sr-only-element">
Search this site
</label>
<AutoSuggest
suggestions={shouldRenderSuggestions ? currentSuggestions : []}
onSuggestionsFetchRequested={handleSuggestionsFetch}
onSuggestionsClearRequested={() => {}}
onSuggestionSelected={handleSubmit}
getSuggestionValue={(hit) => hit.query}
renderSuggestion={(hit) => hit.query}
containerProps={containerProps}
inputProps={inputProps}
renderSuggestionsContainer={({ containerProps, children }) => (
<div
{...containerProps}
aria-label="Search suggestions"
id={listboxId}
>
{children}
</div>
)}
/>
{value && (
<button
type="button"
className="search-input-clear-button"
onClick={() => {
setValue('');
Expand All @@ -113,10 +133,7 @@ const Autocomplete = React.forwardRef((props, ref) => {
aria-label="Clear search input"
>
<span className="search-input-clear-text">Clear</span>
<i
aria-hidden="true"
className="search-input-clear-icon fas fa-times"
/>
<i aria-hidden className="search-input-clear-icon fas fa-times" />
</button>
)}

Expand All @@ -128,7 +145,7 @@ const Autocomplete = React.forwardRef((props, ref) => {
<span className="su-sr-only-element">Submit search</span>
<i
className="search-input-submit-button-icon fas fa-search fa-flip-horizontal"
aria-hidden="true"
aria-hidden
/>
</button>
</form>
Expand Down
29 changes: 16 additions & 13 deletions src/components/search/hits.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@ const Hits = (props) => {

{hits.length > 0 && <Stats />}

{hits.map((hit) => (
<article
className="search-hits-item su-mb-2 su-pb-2 su-px-default"
key={hit.objectID}
>
<Heading level={'h2'} serif={true} weight={'bold'}>
<SbLink link={{ cached_url: `/${hit.slug}` }}>{hit.title}</SbLink>
</Heading>
<p className="su-mb-none">
{hit.intro || hit.teaser || hit.description}
</p>
</article>
))}
<ul className="su-list-none">
{hits.map((hit) => (
<li key={hit.objectID}>
<article className="search-hits-item su-mb-2 su-pb-2 su-px-default">
<Heading level={'h2'} serif={true} weight={'bold'}>
<SbLink link={{ cached_url: `/${hit.slug}` }}>
{hit.title}
</SbLink>
</Heading>
<p className="su-mb-none">
{hit.intro || hit.teaser || hit.description}
</p>
</article>
</li>
))}
</ul>

{hits.length > 0 && <Pagination initialPage={props.initialPage} />}
</div>
Expand Down
17 changes: 10 additions & 7 deletions src/components/search/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Pagination = ({ initialPage }) => {
};

return (
<nav role="navigation" aria-label="Search Results Pagination">
<nav aria-label="Search Results Pagination">
<ul className="search-pagination">
{isPreviousVisible && (
<li className="search-pagination-item search-pagination-item--text">
Expand All @@ -48,10 +48,7 @@ const Pagination = ({ initialPage }) => {
)}
{isFirstPageVisible && (
<>
<li
role="button"
className="search-pagination-item search-pagination-item--mobile-hidden"
>
<li className="search-pagination-item search-pagination-item--mobile-hidden">
<a
onClick={($event) => handlePageChange(1, $event)}
href={`/search-results?page=1`}
Expand All @@ -60,7 +57,10 @@ const Pagination = ({ initialPage }) => {
1
</a>
</li>
<li className="search-pagination-item search-pagination-item--placeholder search-pagination-item--mobile-hidden">
<li
aria-label="ellipsis indicating non-visible pages"
className="search-pagination-item search-pagination-item--placeholder search-pagination-item--mobile-hidden"
>
...
</li>
</>
Expand Down Expand Up @@ -100,7 +100,10 @@ const Pagination = ({ initialPage }) => {
})}
{isLastPageVisible && (
<>
<li className="search-pagination-item search-pagination-item--placeholder search-pagination-item--mobile-hidden">
<li
aria-label="ellipsis indicating non-visible pages"
className="search-pagination-item search-pagination-item--placeholder search-pagination-item--mobile-hidden"
>
...
</li>
<li className="search-pagination-item search-pagination-item--mobile-hidden">
Expand Down
31 changes: 28 additions & 3 deletions src/components/search/searchOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ const SearchOverlay = () => {
const [isEmptyErrorVisible, setIsEmptyErrorVisible] = useState(false);
const inputRef = useRef(null);

const searchButton =
typeof window !== 'undefined' &&
document.querySelector('.ood-header__search-button');

const focusSearchButton = () => {
if (searchButton) {
// wait 100ms, then focus on search button
setTimeout(() => searchButton.focus(), 100);
}
};

useEffect(() => {
if (isOpen && inputRef.current) {
// when the search overlay opens, immediately give focus to the input
Expand All @@ -43,7 +54,13 @@ const SearchOverlay = () => {
setIsEmptyErrorVisible(false);
};

UseEscape(() => isOpen && closeSearchOverlay());
const handleCloseOverlay = () => {
closeSearchOverlay();
focusSearchButton();
};

// close search overlay and focus search button
UseEscape(() => isOpen && handleCloseOverlay());

const {
introduction,
Expand All @@ -63,14 +80,20 @@ const SearchOverlay = () => {
UseFocusTrap(firstTabbableRef, lastTabbableRef, isOpen);

return (
<div className={`search-overlay ${isOpen ? 'visible' : 'hidden'}`}>
<div
role="dialog"
aria-modal
aria-label="Search this site"
className={`search-overlay ${isOpen ? 'visible' : 'hidden'}`}
>
<LocationProvider>
<CenteredContainer classes="search-container su-pt-5" flex={true}>
<FlexCell lg={11} xl={9} xxl={8} classes="su-mx-auto">
<div className="search-header">
<button
type="button"
className="search-close-button"
onClick={closeSearchOverlay}
onClick={handleCloseOverlay}
ref={firstTabbableRef}
aria-label="Close Search"
>
Expand All @@ -95,6 +118,8 @@ const SearchOverlay = () => {
>
{isOpen && (
<Autocomplete
inputId="search-overlay-input"
listboxId="search-overlay-listbox"
onSubmit={submitTerm}
onSuggestionCleared={handleSuggestionCleared}
ref={inputRef}
Expand Down
3 changes: 3 additions & 0 deletions src/components/search/searchResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ const SearchResults = (props) => {
searchClient={searchClient}
indexName={process.env.GATSBY_ALGOLIA_SUGGESTIONS_INDEX_NAME}
>
{/* This is the search bar on the search results page */}
<Autocomplete
inputId="search-page-input"
listboxId="search-page-listbox"
onSubmit={handleSubmit}
onSuggestionCleared={handleSuggestionCleared}
/>
Expand Down
5 changes: 3 additions & 2 deletions src/components/search/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from 'react';
import { connectStats } from 'react-instantsearch-dom';

const Stats = connectStats(({ nbHits }) => (
<p className="search-stats">
<strong>{nbHits}</strong>&nbsp;{nbHits !== 1 ? 'results' : 'result'} found:
<p className="search-stats" aria-live="polite" aria-atomic>
<strong>{nbHits}</strong>
{nbHits !== 1 ? ' results' : ' result'} found:
</p>
));

Expand Down
1 change: 1 addition & 0 deletions src/scss/components/search/_input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
&--highlighted {
color: $su-color-digital-red;
background-color: $su-color-black-10;
text-decoration: underline;
}
}

Expand Down
Loading