Skip to content

Commit 4d39db7

Browse files
authored
fix: remove the search field from the playground (#1948)
Closes #1544 * fix: remove the search field from the playground This search-field raises accessibility issues from rendering results after a search. Fixing the issues is complex. Since the component is hardly used, we remove it to mitigate the accessibility issues. * fix: use CSS rules to avoid flashing when removing the search field
1 parent 39774a0 commit 4d39db7

File tree

1 file changed

+4
-48
lines changed

1 file changed

+4
-48
lines changed

.storybook/manager-head.html

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -93,53 +93,6 @@
9393

9494
sidebarNode.insertBefore(usefulLinksContainer, sidebarNode.childNodes[1]);
9595

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-
14396
const sidebarSubheading = document.getElementsByClassName("sidebar-subheading");
14497
if (sidebarSubheading) {
14598
for (let i = 0; i < sidebarSubheading.length; i++) {
@@ -157,6 +110,7 @@
157110
}
158111
}
159112
}
113+
160114
function setArialLabelForExpandCollapseBtn() {
161115
const expandCollapseBtns = document.getElementsByClassName("css-rl1ij0");
162116
if (expandCollapseBtns) {
@@ -180,7 +134,6 @@
180134
}
181135

182136
setEventOnMenuClick();
183-
setListItemsAc11y();
184137
}
185138

186139
function createSvg(svgPath) {
@@ -434,4 +387,7 @@
434387
.css-14o7vtb:focus-visible {
435388
outline: auto;
436389
}
390+
.search-field {
391+
display: none !important;
392+
}
437393
</style>

0 commit comments

Comments
 (0)