Skip to content

Commit d65667b

Browse files
authoredJul 14, 2022
fix(theme): prevent docsearch button key from changing (#986)
1 parent afd905c commit d65667b

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed
 

Diff for: ‎src/client/theme-default/components/VPNavBarSearch.vue

+22-5
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ const { theme } = useData()
1414
// hit the hotkey to invoke it.
1515
const loaded = ref(false)
1616
17-
const metaKey = ref()
17+
const metaKey = ref(`'Meta'`)
1818
1919
onMounted(() => {
2020
if (!theme.value.algolia) {
2121
return
2222
}
2323
2424
// meta key detect (same logic as in @docsearch/js)
25-
metaKey.value.textContent = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)
26-
? ''
27-
: 'Ctrl'
25+
metaKey.value = /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)
26+
? `'⌘'`
27+
: `'Ctrl'`
2828
2929
const handleSearchHotKey = (e: KeyboardEvent) => {
3030
if (e.key === 'k' && (e.ctrlKey || e.metaKey)) {
@@ -79,7 +79,7 @@ function load() {
7979
<span class="DocSearch-Button-Placeholder">{{ theme.algolia?.buttonText || 'Search' }}</span>
8080
</span>
8181
<span class="DocSearch-Button-Keys">
82-
<kbd class="DocSearch-Button-Key" ref="metaKey">Meta</kbd>
82+
<kbd class="DocSearch-Button-Key"></kbd>
8383
<kbd class="DocSearch-Button-Key">K</kbd>
8484
</span>
8585
</button>
@@ -255,6 +255,23 @@ function load() {
255255
padding-right: 6px;
256256
}
257257
258+
.DocSearch-Button .DocSearch-Button-Key:first-child {
259+
font-size: 1px;
260+
letter-spacing: -1px;
261+
color: transparent;
262+
}
263+
264+
.DocSearch-Button .DocSearch-Button-Key:first-child:after {
265+
content: v-bind(metaKey);
266+
font-size: 12px;
267+
letter-spacing: normal;
268+
color: var(--docsearch-muted-color);
269+
}
270+
271+
.DocSearch-Button .DocSearch-Button-Key:first-child > * {
272+
display: none;
273+
}
274+
258275
.dark .DocSearch-Footer {
259276
border-top: 1px solid var(--vp-c-divider);
260277
}

0 commit comments

Comments
 (0)