mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-23 14:23:39 -04:00
Fixed content tabs stealing keyboard access to search
This commit is contained in:
@@ -56,16 +56,26 @@ export interface Keyboard {
|
||||
* Check whether an element may receive keyboard input
|
||||
*
|
||||
* @param el - Element
|
||||
* @param type - Key type
|
||||
*
|
||||
* @returns Test result
|
||||
*/
|
||||
function isSusceptibleToKeyboard(el: HTMLElement): boolean {
|
||||
switch (el.tagName) {
|
||||
function isSusceptibleToKeyboard(
|
||||
el: HTMLElement, type: string
|
||||
): boolean {
|
||||
switch (el.constructor) {
|
||||
|
||||
/* Form elements */
|
||||
case "INPUT":
|
||||
case "SELECT":
|
||||
case "TEXTAREA":
|
||||
/* Input elements */
|
||||
case HTMLInputElement:
|
||||
/* @ts-expect-error - omit unnecessary type cast */
|
||||
if (el.type === "radio")
|
||||
return /^Arrow/.test(type)
|
||||
else
|
||||
return true
|
||||
|
||||
/* Select element and textarea */
|
||||
case HTMLSelectElement:
|
||||
case HTMLTextAreaElement:
|
||||
return true
|
||||
|
||||
/* Everything else */
|
||||
@@ -95,11 +105,11 @@ export function watchKeyboard(): Observable<Keyboard> {
|
||||
ev.stopPropagation()
|
||||
}
|
||||
} as Keyboard)),
|
||||
filter(({ mode }) => {
|
||||
filter(({ mode, type }) => {
|
||||
if (mode === "global") {
|
||||
const active = getActiveElement()
|
||||
if (typeof active !== "undefined")
|
||||
return !isSusceptibleToKeyboard(active)
|
||||
return !isSusceptibleToKeyboard(active, type)
|
||||
}
|
||||
return true
|
||||
}),
|
||||
|
||||
@@ -163,7 +163,7 @@ export async function handler(
|
||||
* Worker
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/* @ts-ignore - expose Lunr.js in global scope, or stemmers will not work */
|
||||
/* @ts-expect-error - expose Lunr.js in global scope, or stemmers won't work */
|
||||
self.lunr = lunr
|
||||
|
||||
/* Handle messages */
|
||||
|
||||
Reference in New Issue
Block a user