Don't focus search bar on touch screens

This commit is contained in:
Martin Berg Alstad 2023-03-15 19:59:51 +01:00
parent e6dc365632
commit 401e5bda08
2 changed files with 15 additions and 4 deletions

7
src/functions/touch.ts Normal file
View File

@ -0,0 +1,7 @@
/**
* Check if the device is touch enabled
* @returns {boolean} True if the device is touch enabled, otherwise false
*/
export function isTouch(): boolean {
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
}

View File

@ -23,6 +23,7 @@ import { Button, MySwitch } from "./components/button";
import MyDialog from "./components/dialog";
import { exportToExcel } from "./functions/export";
import { Link } from "./components/link";
import { isTouch } from "./functions/touch";
type Option = { name: string, value: "NONE" | "TRUE" | "FALSE" | "DEFAULT" | "TRUE_FIRST" | "FALSE_FIRST" };
@ -41,9 +42,10 @@ const TruthTablePage: Component = () => {
if (searchParams.has("exp")) {
inputContent = true;
}
if (searchParams.has("hideIntermediate")) {
hideIntermediate = searchParams.get("hideIntermediate") === "true";
} }
if (searchParams.has("hideIntermediate")) {
hideIntermediate = searchParams.get("hideIntermediate") === "true";
}
}
/**
* Stores the boolean value of the simplify toggle
@ -160,7 +162,9 @@ hideIntermediate=${ hideIntermediates() }`)
}
// Focuses searchbar on load
getInputElement()?.focus();
if (!isTouch()) {
getInputElement()?.focus();
}
});
function _exportToExcel(): void {