-
Notifications
You must be signed in to change notification settings - Fork 719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Search as ARIA spec compliant* dialog and combobox pattern #2831
base: master
Are you sure you want to change the base?
Implement Search as ARIA spec compliant* dialog and combobox pattern #2831
Conversation
- Add top margin to `.tsd-breadcrumb` in mobile screen - Remove top margin from `.tsd-navigation.settings` - Remove top padding from `.col-sidebar` on single sidebar - Remove margin for `.site-menu` on larger screens
- Move selectors (`#tsd-toolbar-links`, tag selectors) to a relevant place. - Remove classes (`.table-cell`, `.no-caption`, `.tsd-toolbar-icon`), and merge their styles to other common classes.
…cript - **theme_search_index_not_available** - **theme_search_no_results** - theme_search_placeholder - **theme_search_no_recent_searches**
- Use HTML dialog element as popup - Use ARIA-spec compliant "combobox with list autocomplete" pattern for search - Add entry animations - Comment out affected dead code for keyboard event listeners
- store recent searches (that were clicked) in localStorage, with `tsd-search-recent` key - Omit `matchData` property in `res`'s type to make it compatible with recent searches stored in localStorage. - This implementation prevents broken links, but refs might change, changing the suggestions
src/lib/output/themes/default/assets/typedoc/components/Search.ts
Outdated
Show resolved
Hide resolved
src/lib/output/themes/default/assets/typedoc/components/Search.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple general issues:
- With no search history, typing something and then clearing the search field results in the claim "No Recent Searches"... which is rather confusing, I just searched for something! Didn't click on anything, but... maybe that's expected, but it greatly confused me for a bit.
- This introduced some contrast issues in the new search dialog (run chromium's lighthouse checks)
This is looking really awesome! It seems to behave significantly better on mobile and I like the change on desktop as well
Regarding the recent searches message, yup, totally agree, I think even left a comment about in the code that it's actually search results. I picked up it up from remix.run, and I'm confused what to show there, "no recent... What?" |
Would it be better to just not show anything there? It's a different dialog size, but just showing a search bar the first time it is opened doesn't seem completely wrong to me. I also just realized that storing IDs is not necessarily the way we should go about that. IDs are somewhat likely to change between rebuilds of the site as they are dependent on conversion order, so if the very first class TypeDoc converts gets a new property, all the IDs will end up shifted. |
Edit: Removing it. ...Yup, I mainly added for cosmetic UX purposes. It's not important and I already had doubts about it (that's why it's the last commit).Without anything it feels.. empty. I'll get some quick design advice on this, otherwise I'll just remove it. And yes I tested the change of IDs, I still added it on the premises that atleast it won't crash. From commit message:
It was the simplest way to achieve it, and I don't wanna make it complicated, so I'll probably just remove it. But I don't think occasional changing suggestions is a big deal. But after all, it is a bug. So here's my confusion:
Tradeoffs everywhere.. What are your thoughts about it? |
- fix typo (requierd -> required) - Remove unnecessary try-catch - Add falsy check for document.getElementById argument to avoid console warning in firefox
All children of a listbox must be options, showing error message in an li tag without role=option was invalid. An alternative approach is to use another element with aria-live=polite attribute, to announce the results to the user. However, consecutive queries with no results wouldn't be announced (because the message would be the same), so add search query as part of the message to make it dynamic - Add a new element with aria-live and aria-atomic attributes for a helpful message - Remove unnecessary attribute selector for search results. - Add styles height/margin styles for non-empty elements only. - Add maxLength to input
src/lib/output/themes/default/assets/typedoc/components/Search.ts
Outdated
Show resolved
Hide resolved
} | ||
|
||
const item = document.createElement("li"); | ||
item.id = `tsd-search:${optionsIdCounter}-${i}`; | ||
item.role = "option"; | ||
item.ariaSelected = "false"; | ||
item.classList.value = row.classes ?? ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Figure out how to override filter styles to not affect search results
- Add background-active and contrast-text css properties - update text-aside, menu-item-active color in light theme - break light and dark colors in separate selectors to make them easier to work with "contrast-text" slightly improves contrast. though, not enough to pass WCAG level AAA
Pretty much a complete rewrite of the UI and UI logic for search.
UI Changes:
ready
class from search element.More details are in commit messages. I haven't updated the changelog, because I don't know what's relevant.
Visual Regression script probably won't detect the change?
*Mostly. There might be minor variations