navbar: Allow the typing of slash in input/textarea fields
This commit is contained in:
@@ -17,9 +17,10 @@
|
|||||||
|
|
||||||
// Event listener for focusing input
|
// Event listener for focusing input
|
||||||
function handleKeydown(event: KeyboardEvent) {
|
function handleKeydown(event: KeyboardEvent) {
|
||||||
if (event.key === '/' && document.activeElement !== inputElement) {
|
// Ignore any keypresses in an input/textarea field, so we don't interfere with typing.
|
||||||
|
if (event.key === '/' && !["INPUT", "TEXTAREA"].includes((event.target as HTMLElement)?.tagName)) {
|
||||||
event.preventDefault(); // Prevent browser's search shortcut
|
event.preventDefault(); // Prevent browser's search shortcut
|
||||||
if (inputElement) {
|
if (inputElement) {
|
||||||
inputElement.focus();
|
inputElement.focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,7 +223,7 @@
|
|||||||
bind:value={query}
|
bind:value={query}
|
||||||
class="grow"
|
class="grow"
|
||||||
placeholder={$t('navbar.search')}
|
placeholder={$t('navbar.search')}
|
||||||
bind:this={inputElement}
|
bind:this={inputElement}
|
||||||
/><kbd class="kbd">/</kbd>
|
/><kbd class="kbd">/</kbd>
|
||||||
</label>
|
</label>
|
||||||
<button on:click={searchGo} type="submit" class="btn btn-neutral"
|
<button on:click={searchGo} type="submit" class="btn btn-neutral"
|
||||||
|
|||||||
Reference in New Issue
Block a user