-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hotfix(autocomplete): use separate panelContainer (#1787)
this fixes a Safari bug where the tab order traps keyboard focus in between the autocomplete input and submit buttons. the bug only happened on Safari, when using the React renderer instead of the default Preact renderer. some CSS refactoring was needed to target elements that are inside the new panelContainer element.
- Loading branch information
1 parent
80cfd78
commit d56caa3
Showing
6 changed files
with
261 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,131 +1,137 @@ | ||
@import '@algolia/autocomplete-theme-classic'; | ||
|
||
.aa-Autocomplete { | ||
--aa-icon-color-rgb: 22, 92, 150; // $brand-primary; | ||
--aa-primary-color-rgb: 22, 92, 150; // $brand-primary; | ||
--aa-search-input-height: 2.25rem; | ||
} | ||
|
||
// right now #header-desktop is the only search using the new library, so it's | ||
// the only one styled here. the #header-desktop can be removed once we migrate | ||
// the rest over | ||
.c-search-bar__autocomplete#header-desktop { | ||
.aa-Autocomplete { | ||
--aa-icon-color-rgb: 22, 92, 150; // $brand-primary; | ||
--aa-primary-color-rgb: 22, 92, 150; // $brand-primary; | ||
--aa-search-input-height: 2.25rem; | ||
} | ||
|
||
.aa-Item { | ||
@include icon-size-inline(1em); | ||
border-bottom: $border; | ||
border-radius: 0; | ||
font-weight: normal; | ||
|
||
&:hover { | ||
background-color: $brand-primary-lightest; | ||
#header-desktop { | ||
.c-search-bar__autocomplete { | ||
.aa-Label { | ||
margin-bottom: unset; | ||
} | ||
|
||
em { | ||
font-style: inherit; | ||
font-weight: bold; | ||
.aa-Input { | ||
// stylelint-disable-next-line declaration-no-important | ||
height: var(--aa-search-input-height) !important; | ||
} | ||
|
||
> a, | ||
> button { | ||
color: currentColor; | ||
display: flex; | ||
font-weight: inherit; | ||
gap: .25rem; | ||
min-width: 0; | ||
padding: calc(#{$base-spacing} / 2) $base-spacing; | ||
.aa-InputWrapperPrefix { | ||
order: 3; // move search icon to end. | ||
} | ||
|
||
a:hover { | ||
text-decoration: none; | ||
.aa-InputWrapper { | ||
order: 1; | ||
padding-left: 1rem; | ||
} | ||
} | ||
|
||
.aa-ItemContent, | ||
.aa-ItemContentBody { | ||
display: unset; | ||
} | ||
|
||
.aa-ItemContent { | ||
mark { | ||
padding: 0; | ||
.aa-InputWrapperSuffix { | ||
order: 2; | ||
} | ||
> * { | ||
margin-right: .25rem; | ||
} | ||
} | ||
|
||
.aa-ItemContentTitle { | ||
display: unset; | ||
margin: unset; | ||
overflow: visible; | ||
text-overflow: unset; | ||
white-space: normal; | ||
} | ||
|
||
.aa-PanelLayout { | ||
padding: unset; | ||
} | ||
.aa-Form { | ||
border: 3px solid $brand-primary; | ||
border-radius: .5rem; | ||
|
||
.aa-Panel { | ||
// stylelint-disable-next-line declaration-no-important | ||
top: 3.25rem !important; | ||
z-index: var(--aa-base-z-index); | ||
} | ||
&:focus-within { | ||
border-color: $brand-primary-lightest; | ||
box-shadow: unset; | ||
} | ||
} | ||
|
||
.aa-Label { | ||
margin-bottom: unset; | ||
} | ||
.aa-LoadingIndicator, | ||
.aa-SubmitButton { | ||
padding-left: var(--aa-spacing-half); | ||
width: calc(var(--aa-spacing) * 1.25 + var(--aa-icon-size) - 1px); | ||
} | ||
|
||
.aa-Input { | ||
// stylelint-disable-next-line declaration-no-important | ||
height: var(--aa-search-input-height) !important; | ||
} | ||
.aa-ClearButton { | ||
@include fa-icon-solid($fa-var-times-circle); | ||
color: rgba(var(--aa-icon-color-rgb), var(--aa-icon-color-alpha)); | ||
padding-right: var(--aa-spacing-half); | ||
// hide default icon | ||
.aa-ClearIcon { display: none; } | ||
} | ||
|
||
.aa-InputWrapperPrefix { | ||
order: 3; // move search icon to end. | ||
} | ||
.aa-SubmitButton { | ||
@include fa-icon-solid($fa-var-search); | ||
color: rgba(var(--aa-icon-color-rgb), var(--aa-icon-color-alpha)); | ||
// hide default icon | ||
.aa-SubmitIcon { display: none; } | ||
} | ||
|
||
.aa-InputWrapper { | ||
order: 1; | ||
padding-left: 1rem; | ||
.aa-GradientBottom, | ||
.aa-GradientTop { all: unset; } | ||
} | ||
|
||
.aa-InputWrapperSuffix { | ||
order: 2; | ||
} | ||
.c-search-bar__autocomplete-results { | ||
.aa-ItemContent { | ||
mark { | ||
padding: 0; | ||
} | ||
> * { | ||
margin-right: .25rem; | ||
} | ||
} | ||
|
||
.aa-Form { | ||
border: 3px solid $brand-primary; | ||
border-radius: .5rem; | ||
.aa-ItemContentTitle { | ||
display: unset; | ||
margin: unset; | ||
overflow: visible; | ||
text-overflow: unset; | ||
white-space: normal; | ||
} | ||
|
||
&:focus-within { | ||
border-color: $brand-primary-lightest; | ||
box-shadow: unset; | ||
.aa-PanelLayout { | ||
padding: unset; | ||
} | ||
} | ||
|
||
.aa-LoadingIndicator, | ||
.aa-SubmitButton { | ||
padding-left: var(--aa-spacing-half); | ||
width: calc(var(--aa-spacing) * 1.25 + var(--aa-icon-size) - 1px); | ||
} | ||
.aa-Panel { | ||
// stylelint-disable-next-line declaration-no-important | ||
top: 3.25rem !important; | ||
z-index: var(--aa-base-z-index); | ||
} | ||
|
||
.aa-ClearButton { | ||
@include fa-icon-solid($fa-var-times-circle); | ||
color: rgba(var(--aa-icon-color-rgb), var(--aa-icon-color-alpha)); | ||
padding-right: var(--aa-spacing-half); | ||
// hide default icon | ||
.aa-ClearIcon { display: none; } | ||
} | ||
.aa-Item { | ||
border-bottom: $border; | ||
border-radius: 0; | ||
font-weight: normal; | ||
|
||
&:hover { | ||
background-color: $brand-primary-lightest; | ||
} | ||
|
||
em { | ||
font-style: inherit; | ||
font-weight: bold; | ||
} | ||
|
||
> a, | ||
> button { | ||
color: currentColor; | ||
display: flex; | ||
font-weight: inherit; | ||
gap: .25rem; | ||
min-width: 0; | ||
padding: calc(#{$base-spacing} / 2) $base-spacing; | ||
} | ||
|
||
a:hover { | ||
text-decoration: none; | ||
} | ||
|
||
[class*=c-svg__icon] { | ||
width: 1em; | ||
} | ||
} | ||
|
||
.aa-SubmitButton { | ||
@include fa-icon-solid($fa-var-search); | ||
color: rgba(var(--aa-icon-color-rgb), var(--aa-icon-color-alpha)); | ||
// hide default icon | ||
.aa-SubmitIcon { display: none; } | ||
.aa-ItemContent, | ||
.aa-ItemContentBody { | ||
display: unset; | ||
} | ||
} | ||
|
||
.aa-GradientBottom, | ||
.aa-GradientTop { all: unset; } | ||
} | ||
|
Oops, something went wrong.