mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-26 02:57:45 +01:00
780ddef241
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
1 line
1.2 KiB
JavaScript
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)}))})); |