fix(core): 🐛 inconsistent search focus behavior

This commit is contained in:
alistair3149 2023-07-16 03:50:43 -04:00
parent 6af0900185
commit 1aba52b870
No known key found for this signature in database
GPG key ID: 16076C01E5C88864

View file

@ -169,11 +169,11 @@ function renderSearchClearButton( input ) {
input.focus();
} );
input.addEventListener( 'input', ( event ) => {
if ( event.target.value === '' ) {
input.addEventListener( 'input', () => {
if ( input.value === '' ) {
clearButton.remove();
} else {
event.target.after( clearButton );
input.after( clearButton );
}
} );
}
@ -204,13 +204,13 @@ function initSearch( window ) {
if ( isPrimarySearch ) {
const checkbox = document.getElementById( 'citizen-search__checkbox' );
bindExpandOnSlash( window, checkbox, input );
renderSearchClearButton( input );
// Focus when toggled
checkbox.addEventListener( 'input', () => {
focusOnChecked( checkbox, input );
} );
}
renderSearchClearButton( input );
setLoadingIndicatorListeners( searchBox, true, renderSearchLoadingIndicator );
loadSearchModule( input, searchModule, () => {
setLoadingIndicatorListeners( searchBox, false, renderSearchLoadingIndicator );