WordPress/wp-includes/blocks/search/view.min.js
isabel_brison 780ddef241 Editor: update npm packages with second round of bug fixes for 6.3 RC1.
Includes miscellaneous bug fixes for 6.3 RC1.

Props ramonopoly, mukesh27.
Fixes #58804.

Built from https://develop.svn.wordpress.org/trunk@56255


git-svn-id: http://core.svn.wordpress.org/trunk@55767 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-07-18 07:20:48 +00:00

1 line
1.2 KiB
JavaScript

window.addEventListener("DOMContentLoaded",(()=>{const e="wp-block-search__searchfield-hidden";Array.from(document.getElementsByClassName("wp-block-search__button-behavior-expand")).forEach((t=>{const r=t.querySelector(".wp-block-search__input"),a=t.querySelector(".wp-block-search__button"),i=t.querySelector(".wp-block-search__label"),s=a.getAttribute("aria-label"),o=r.getAttribute("id"),c=i=>i?(r.removeAttribute("aria-hidden"),r.removeAttribute("tabindex"),a.removeAttribute("aria-expanded"),a.removeAttribute("aria-controls"),a.setAttribute("type","submit"),a.setAttribute("aria-label","Submit Search"),t.classList.remove(e)):(a.removeAttribute("type"),r.setAttribute("aria-hidden","true"),r.setAttribute("tabindex","-1"),a.setAttribute("aria-expanded","false"),a.setAttribute("aria-controls",o),a.setAttribute("aria-label",s),t.classList.add(e)),d=e=>e.target.closest(".wp-block-search")?"Escape"===e.key?(a.focus(),c(!1)):void 0:c(!1),n=a=>{t.classList.contains(e)&&(a.preventDefault(),r.focus(),c(!0))};a.removeAttribute("type"),r.addEventListener("keydown",(e=>{d(e)})),a.addEventListener("click",n),a.addEventListener("keydown",(e=>{d(e)})),i&&i.addEventListener("click",n),document.body.addEventListener("click",d)}))}));