|
93 | 93 |
|
94 | 94 | sidebarNode.insertBefore(usefulLinksContainer, sidebarNode.childNodes[1]); |
95 | 95 |
|
96 | | - const searchBox = document.querySelector(".search-field"); |
97 | | - if (searchBox) { |
98 | | - searchBox.setAttribute("name", "Find Components"); |
99 | | - searchBox.setAttribute("aria-expanded", "false"); |
100 | | - |
101 | | - const searchInput = searchBox.querySelector("input"); |
102 | | - if (searchInput) { |
103 | | - searchInput.addEventListener("mouseleave", addAriaExpanded("false")); |
104 | | - searchInput.addEventListener("mouseout", addAriaExpanded("false")); |
105 | | - searchInput.addEventListener("pointerleave", addAriaExpanded("false")); |
106 | | - searchInput.addEventListener("pointerout", addAriaExpanded("false")); |
107 | | - searchInput.addEventListener("click", addAriaExpanded("true")); |
108 | | - searchInput.addEventListener("focusout", addAriaExpanded("false")); |
109 | | - searchInput.addEventListener("focus", setListItemsAc11y); |
110 | | - } |
111 | | - } |
112 | | - |
113 | | - function setListItemsAc11y() { |
114 | | - const recentMenu = document.querySelector("#storybook-explorer-menu"); |
115 | | - if (recentMenu) { |
116 | | - const firstLi = recentMenu.querySelector("li"); |
117 | | - if (firstLi) { |
118 | | - firstLi.setAttribute("role", "heading"); |
119 | | - firstLi.setAttribute("aria-level", "2"); |
120 | | - } |
121 | | - |
122 | | - const otherLis = recentMenu.querySelectorAll("li:not(:first-child)"); |
123 | | - if (otherLis && otherLis.length > 0) { |
124 | | - for (let i = 0; i < otherLis.length; i++) { |
125 | | - const li = otherLis[i]; |
126 | | - const liText = li.innerText; |
127 | | - if (liText) { |
128 | | - li.setAttribute("aria-label", liText.trim()); |
129 | | - } |
130 | | - li.setAttribute("aria-hidden", "true"); |
131 | | - } |
132 | | - } |
133 | | - } |
134 | | - } |
135 | | - |
136 | | - function addAriaExpanded(value) { |
137 | | - const searchBox = document.querySelector(".search-field"); |
138 | | - if (searchBox) { |
139 | | - searchBox.setAttribute("aria-expanded", value); |
140 | | - } |
141 | | - } |
142 | | - |
143 | 96 | const sidebarSubheading = document.getElementsByClassName("sidebar-subheading"); |
144 | 97 | if (sidebarSubheading) { |
145 | 98 | for (let i = 0; i < sidebarSubheading.length; i++) { |
|
157 | 110 | } |
158 | 111 | } |
159 | 112 | } |
| 113 | + |
160 | 114 | function setArialLabelForExpandCollapseBtn() { |
161 | 115 | const expandCollapseBtns = document.getElementsByClassName("css-rl1ij0"); |
162 | 116 | if (expandCollapseBtns) { |
|
180 | 134 | } |
181 | 135 |
|
182 | 136 | setEventOnMenuClick(); |
183 | | - setListItemsAc11y(); |
184 | 137 | } |
185 | 138 |
|
186 | 139 | function createSvg(svgPath) { |
|
434 | 387 | .css-14o7vtb:focus-visible { |
435 | 388 | outline: auto; |
436 | 389 | } |
| 390 | + .search-field { |
| 391 | + display: none !important; |
| 392 | + } |
437 | 393 | </style> |
0 commit comments