Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/partials/algolia-search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/lite/builds/browser.umd.js" integrity="sha256-w/rbJ5CGTW5rub22bQ/VEoIHxypNh4NZPdkIJvGMZlI=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/instantsearch.production.min.js" integrity="sha256-FOU2owonNoOmNxF4I8jLR4D8w/vziYNi64GUN2boXRQ=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/@algolia/autocomplete-js@1"></script>
<script src="https://cdn.jsdelivr.net/npm/@algolia/autocomplete-js@1.19.4/dist/umd/index.production.js" integrity="VaQwRODmAHrukHfV+gCLjVfzWyj0veQpSK9hu77pt6A=" crossorigin="anonymous"></script>

{{#if page.component}}
<script>
Expand Down Expand Up @@ -235,6 +235,7 @@
openOnFocus: true,
defaultActiveItemId: 0,
detachedMediaQuery: '',
enterKeyHint: 'search',
reshape({ sourcesBySourceId }) {
const { algolia, ...rest } =
sourcesBySourceId;
Expand Down Expand Up @@ -367,6 +368,10 @@
<kbd class="aa-Key">↑</kbd>
<kbd class="aa-Key">↓</kbd>
<span class="aa-KeyLabel">to navigate</span>
<kbd class="aa-Key">
${'platform' in navigator && navigator.platform.toLowerCase().includes('mac') ? html`⌘+K` : html`ctrl+K`}
</kbd>
<span class="aa-KeyLabel">to open</span>
<kbd class="aa-Key">esc</kbd>
<span class="aa-KeyLabel">to close</span>
</div>
Expand All @@ -392,6 +397,16 @@
}
}, true);

window.addEventListener("keydown", (event) => {
const isMac = 'platform' in navigator && navigator.platform.toLowerCase().includes('mac');
const isModifierPressed = isMac ? event.metaKey : event.ctrlKey;
if (isModifierPressed && event.key === "k") {
setIsOpen(true);
event.stopImmediatePropagation();
event.preventDefault();
}
});

document.addEventListener('change', (event) => {
if (event.target.id === 'componentSelect') {
currentComponent = event.target.value;
Expand Down