Merged in feature/81-dev-dev01 (pull request #5)
auto-patch 81-dev-dev01-2023-12-05T22_45_26 * auto-patch 81-dev-dev01-2023-12-05T22_45_26
This commit is contained in:
@@ -1,69 +1,101 @@
|
||||
/******/ (function() { // webpackBootstrap
|
||||
var __webpack_exports__ = {};
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const hiddenClass = 'wp-block-search__searchfield-hidden';
|
||||
Array.from(document.getElementsByClassName('wp-block-search__button-behavior-expand')).forEach(block => {
|
||||
const searchField = block.querySelector('.wp-block-search__input');
|
||||
const searchButton = block.querySelector('.wp-block-search__button');
|
||||
const searchLabel = block.querySelector('.wp-block-search__label');
|
||||
const ariaLabel = searchButton.getAttribute('aria-label');
|
||||
const id = searchField.getAttribute('id');
|
||||
"use strict";
|
||||
(self["__WordPressPrivateInteractivityAPI__"] = self["__WordPressPrivateInteractivityAPI__"] || []).push([[222],{
|
||||
|
||||
const toggleSearchField = showSearchField => {
|
||||
if (showSearchField) {
|
||||
searchField.removeAttribute('aria-hidden');
|
||||
searchField.removeAttribute('tabindex');
|
||||
searchButton.removeAttribute('aria-expanded');
|
||||
searchButton.removeAttribute('aria-controls');
|
||||
searchButton.setAttribute('type', 'submit');
|
||||
searchButton.setAttribute('aria-label', 'Submit Search');
|
||||
return block.classList.remove(hiddenClass);
|
||||
/***/ 534:
|
||||
/***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
|
||||
|
||||
/* harmony import */ var _wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(754);
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
(0,_wordpress_interactivity__WEBPACK_IMPORTED_MODULE_0__/* .store */ .h)({
|
||||
selectors: {
|
||||
core: {
|
||||
search: {
|
||||
ariaLabel: ({
|
||||
context
|
||||
}) => {
|
||||
const {
|
||||
ariaLabelCollapsed,
|
||||
ariaLabelExpanded
|
||||
} = context.core.search;
|
||||
return context.core.search.isSearchInputVisible ? ariaLabelExpanded : ariaLabelCollapsed;
|
||||
},
|
||||
ariaControls: ({
|
||||
context
|
||||
}) => {
|
||||
return context.core.search.isSearchInputVisible ? null : context.core.search.inputId;
|
||||
},
|
||||
type: ({
|
||||
context
|
||||
}) => {
|
||||
return context.core.search.isSearchInputVisible ? 'submit' : 'button';
|
||||
},
|
||||
tabindex: ({
|
||||
context
|
||||
}) => {
|
||||
return context.core.search.isSearchInputVisible ? '0' : '-1';
|
||||
}
|
||||
}
|
||||
|
||||
searchButton.removeAttribute('type');
|
||||
searchField.setAttribute('aria-hidden', 'true');
|
||||
searchField.setAttribute('tabindex', '-1');
|
||||
searchButton.setAttribute('aria-expanded', 'false');
|
||||
searchButton.setAttribute('aria-controls', id);
|
||||
searchButton.setAttribute('aria-label', ariaLabel);
|
||||
return block.classList.add(hiddenClass);
|
||||
};
|
||||
|
||||
const hideSearchField = e => {
|
||||
if (!e.target.closest('.wp-block-search')) {
|
||||
return toggleSearchField(false);
|
||||
}
|
||||
|
||||
if (e.key === 'Escape') {
|
||||
searchButton.focus();
|
||||
return toggleSearchField(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleButtonClick = e => {
|
||||
if (block.classList.contains(hiddenClass)) {
|
||||
e.preventDefault();
|
||||
searchField.focus();
|
||||
toggleSearchField(true);
|
||||
}
|
||||
};
|
||||
|
||||
searchButton.removeAttribute('type');
|
||||
searchField.addEventListener('keydown', e => {
|
||||
hideSearchField(e);
|
||||
});
|
||||
searchButton.addEventListener('click', handleButtonClick);
|
||||
searchButton.addEventListener('keydown', e => {
|
||||
hideSearchField(e);
|
||||
});
|
||||
|
||||
if (searchLabel) {
|
||||
searchLabel.addEventListener('click', handleButtonClick);
|
||||
}
|
||||
|
||||
document.body.addEventListener('click', hideSearchField);
|
||||
});
|
||||
},
|
||||
actions: {
|
||||
core: {
|
||||
search: {
|
||||
openSearchInput: ({
|
||||
context,
|
||||
event,
|
||||
ref
|
||||
}) => {
|
||||
if (!context.core.search.isSearchInputVisible) {
|
||||
event.preventDefault();
|
||||
context.core.search.isSearchInputVisible = true;
|
||||
ref.parentElement.querySelector('input').focus();
|
||||
}
|
||||
},
|
||||
closeSearchInput: ({
|
||||
context
|
||||
}) => {
|
||||
context.core.search.isSearchInputVisible = false;
|
||||
},
|
||||
handleSearchKeydown: store => {
|
||||
const {
|
||||
actions,
|
||||
event,
|
||||
ref
|
||||
} = store;
|
||||
// If Escape close the menu.
|
||||
if (event?.key === 'Escape') {
|
||||
actions.core.search.closeSearchInput(store);
|
||||
ref.querySelector('button').focus();
|
||||
}
|
||||
},
|
||||
handleSearchFocusout: store => {
|
||||
const {
|
||||
actions,
|
||||
event,
|
||||
ref
|
||||
} = store;
|
||||
// If focus is outside search form, and in the document, close menu
|
||||
// event.target === The element losing focus
|
||||
// event.relatedTarget === The element receiving focus (if any)
|
||||
// When focusout is outside the document,
|
||||
// `window.document.activeElement` doesn't change.
|
||||
if (!ref.contains(event.relatedTarget) && event.target !== window.document.activeElement) {
|
||||
actions.core.search.closeSearchInput(store);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/******/ })()
|
||||
;
|
||||
/***/ })
|
||||
|
||||
},
|
||||
/******/ function(__webpack_require__) { // webpackRuntimeModules
|
||||
/******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
|
||||
/******/ var __webpack_exports__ = (__webpack_exec__(534));
|
||||
/******/ }
|
||||
]);
|
||||
Reference in New Issue
Block a user