From e092974a5e0d8a05118257603a2ab379fe0433ec Mon Sep 17 00:00:00 2001 From: atticuscornett <64325242+atticuscornett@users.noreply.github.com> Date: Fri, 15 Mar 2024 01:52:37 -0500 Subject: [PATCH] Make Device Page Keyboard Navigable --- src/Components/DeviceTile.svelte | 43 ++++++++++++++++++++++++++------ src/Components/NavButton.svelte | 2 +- src/Devices.svelte | 8 +++++- 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/Components/DeviceTile.svelte b/src/Components/DeviceTile.svelte index 93eb26c..3fedc85 100644 --- a/src/Components/DeviceTile.svelte +++ b/src/Components/DeviceTile.svelte @@ -6,6 +6,7 @@ export let hoverOptions = true; export let action; export let index; + export let totalDevices; export let viewDevice; @@ -34,9 +35,7 @@ }); function handleKeypress(event){ - console.log(event.key) if (event.key === "Tab"){ - console.log("test"); event.preventDefault(); document.getElementById("device-hover-options-"+index).focus(); } @@ -44,6 +43,24 @@ viewDevice({"i": index}); } } + + function handleHoverKeypress(event){ + if (event.key === "Tab"){ + event.preventDefault(); + event.stopPropagation(); + document.getElementById("device-hover-options-rename-"+index).focus(); + } + } + + function handleHoverButtonKeypress(event){ + console.log(action) + if (event.target.id === "device-hover-options-remove-"+index && (index === totalDevices-1) && (action === "" || + action === false)){ + document.getElementById("nav-Devices").focus(); + event.preventDefault(); + } + event.stopPropagation(); + }