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(); + }
@@ -56,7 +73,7 @@
{mimacroVersion}{(status == "outdated") ? " (outdated)":""}
{#if hoverOptions} -
+
@@ -65,13 +82,13 @@
- +
{#if status !== "disconnected" && status !== "updating"} - +
{/if} - +
{/if} @@ -116,17 +133,25 @@ opacity: 1; } + .HoverOpt:focus-within { + opacity: 1; + } + .HoverOpt > div { display: none; font-size: 10px; } + .HoverOpt:focus-within { + display: block; + } + .HoverOpt:hover > div { display: block; margin-top: 30px; } - .HoverOpt:focus > div { + .HoverOpt:focus-within > div { display: block; margin-top: 30px; } @@ -183,4 +208,8 @@ border: none; border-radius: 3px; } + + button:focus { + outline: white solid 2px; + } \ No newline at end of file diff --git a/src/Components/NavButton.svelte b/src/Components/NavButton.svelte index 854cf69..50b2221 100644 --- a/src/Components/NavButton.svelte +++ b/src/Components/NavButton.svelte @@ -28,7 +28,7 @@
- +