Skip to content
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

v5.2.0: Migrate to DocSearch 3 #36176

Merged
merged 9 commits into from
May 6, 2022
Merged

v5.2.0: Migrate to DocSearch 3 #36176

merged 9 commits into from
May 6, 2022

Conversation

mdo
Copy link
Member

@mdo mdo commented Apr 14, 2022

Screen Shot 2022-04-13 at 5 31 32 PM

Screen Shot 2022-04-13 at 5 31 35 PM

This replaces our current DocSearch 2 implementation with DocSearch 3, including a new dialog that pops up that can save recent searches in local storage. I've lightly restyled things to better suit our docs, but could be down for more changes. Right now this is all done via CDN links, but we could also bring this in via npm or a manual copy-pasta if we prefer that.

Current known issue w/ Safari: algolia/docsearch#1260.

Base branch is #35736, but that'll change after we merge that.

Fixes #33338

site/assets/js/search.js Outdated Show resolved Hide resolved
site/assets/js/search.js Show resolved Hide resolved
@mdo mdo force-pushed the new-masthead branch 3 times, most recently from 4d069dd to f09135b Compare April 18, 2022 05:01
Base automatically changed from new-masthead to main April 18, 2022 05:17
@mdo mdo force-pushed the v520-docsearch3 branch from 611730b to ccbf35b Compare April 20, 2022 02:52
@@ -5,7 +5,7 @@
{{- end }}

{{ if eq .Page.Layout "docs" -}}
<script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should serve this from npm at some point later along with all 3rd-party files.

site/assets/js/search.js Outdated Show resolved Hide resolved
@XhmikosR
Copy link
Member

I added the query back because it's better; we only query it once, we guard the code with it and then we reuse it.

<form class="bd-search" data-shortcut="⌘K">
<input type="search" class="form-control" id="search-input" placeholder="Search docs..." aria-label="Search docs for..." autocomplete="off" data-bd-docs-version="{{ .Site.Params.docs_version }}">
</form>
<div class="bd-search" id="docsearch" data-bd-docs-version="{{ .Site.Params.docs_version }}"></div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patrickhlauke friendly ping to check if we are still OK with a11y :)

@patrickhlauke
Copy link
Member

patrickhlauke commented Apr 21, 2022

urgh, good lord, what have algolia done there...

ok, it's not completely bad, but some right clangers. the dialog lacks a role="dialog" and aria-modal="true", the underlying page is not hidden from assistive tech (aria-hidden="true"), and it's still possible to escape out of the dialog and navigate through the underlying page (e.g. doing Alt+d on Windows to jump to the address bar, then Tab forward back into the page).

also, the oh-so-subtle text colour for the "No recent searches" and the keyboard shortcut/command hints is making my eyes go fuzzy...

image

is there an upstream repository where this can be fed back to them? had a quick look over the algolia site, but nothing jumped out at me directly...

I'd say it's ok to ship it as is for now, but really hoping that we'll be able to punt them into an improved direction

@julien-deramond
Copy link
Member

is there an upstream repository where this can be fed back to them? had a quick look over the algolia site, but nothing jumped out at me directly...

I'd say https://github.com/algolia/docsearch

@mdo
Copy link
Member Author

mdo commented Apr 22, 2022

Pushed a fix for the color contrast as mentioned by @patrickhlauke, alignment issues noted by @julien-deramond, and added some custom styles to tweak the appearance.

@mdo mdo force-pushed the v520-docsearch3 branch from b946079 to 6edbb26 Compare April 22, 2022 01:51
@mdo mdo force-pushed the v520-docsearch3 branch from 6edbb26 to 2a239f8 Compare April 22, 2022 23:23
@patrickhlauke
Copy link
Member

for what it's worth, filed this issue with algolia algolia/docsearch#1370

@patrickhlauke
Copy link
Member

thanks @mdo the tweaks to colours/contrast look good

@patrickhlauke
Copy link
Member

patrickhlauke commented Apr 23, 2022

going to mention this here (as not sure where else/if there's a more appropriate issue - if there's a more relevant one, feel free to copy/paste it over there):

the dropdown control in the header to select different bootstrap versions should be a <button> rather than a link - or at very least have a role="button" on that <a> element

I'd tweak the styles so that focus outline is only suppressed when :not(:focus-visible), i.e.

.bd-navbar .dropdown-toggle:focus:not(:focus-visible) {
    outline: 0;
}

otherwise, navigating with keyboard, the focus indication currently is only a very faint change in colour, which is not sufficient.

@mdo mdo force-pushed the v520-docsearch3 branch from 2a239f8 to 7af1906 Compare May 6, 2022 04:52
@mdo mdo merged commit 6b49d26 into main May 6, 2022
@mdo mdo deleted the v520-docsearch3 branch May 6, 2022 23:56
@@ -62,4 +62,5 @@ <h1 class="bd-title mb-0" id="content">{{ .Title | markdownify }}</h1>
{{ range .Page.Params.extra_js -}}
<script{{ with .async }} async{{ end }} src="{{ .src }}"></script>
{{- end -}}
<div class="position-fixed"><input type="text"></div>
Copy link
Member

@louismaximepiton louismaximepiton May 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to disturb this merged PR, but this div/input looks useless to me. Is that a mistake or did I misunderstand something in here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a hack to keep Safari from jumping to the bottom of the page. It's a docsearch bug that hasn't been fixed yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok, thanks a lot for your answer !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BS website search that saves results
6 participants