From ae85b7e6257491de426c2d0a6e2c788a4139c0e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20Br=C3=A5then=20Nomerstad?= Date: Tue, 5 Mar 2024 09:17:58 +0100 Subject: [PATCH] Forbedrer logging av piltast-navigasjon --- src/utils/keyboard-navigation/kb-navigation.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/keyboard-navigation/kb-navigation.ts b/src/utils/keyboard-navigation/kb-navigation.ts index 07df1b174..23952fc92 100644 --- a/src/utils/keyboard-navigation/kb-navigation.ts +++ b/src/utils/keyboard-navigation/kb-navigation.ts @@ -119,7 +119,6 @@ export const selectNode = (node: KbNavNode, callback: NodeSetterCallback = () => if (!element) { return; } - logAmplitudeEvent('piltast-navigasjon', { linkId: node.id, linkGroup: node.group }); callback(node); if (focus) { element.focus(); @@ -127,6 +126,9 @@ export const selectNode = (node: KbNavNode, callback: NodeSetterCallback = () => } }; +const logArrowKeyUsage = (node: KbNavNode) => + logAmplitudeEvent('piltast-navigasjon-2', { linkId: node.id, linkGroup: node.group }); + const arrowkeysHandler = (currentNode: KbNavNode, setCurrentNode: NodeSetterCallback) => (event: KeyboardEvent) => { if (!currentNode?.id) { return; @@ -138,18 +140,22 @@ const arrowkeysHandler = (currentNode: KbNavNode, setCurrentNode: NodeSetterCall return; } selectNode(currentNode[NodeEdge.Left], setCurrentNode); + logArrowKeyUsage(currentNode); break; case 'ArrowUp': selectNode(currentNode[NodeEdge.Top], setCurrentNode); + logArrowKeyUsage(currentNode); break; case 'ArrowRight': if (isInputField(currentNode)) { return; } selectNode(currentNode[NodeEdge.Right], setCurrentNode); + logArrowKeyUsage(currentNode); break; case 'ArrowDown': selectNode(currentNode[NodeEdge.Bottom], setCurrentNode); + logArrowKeyUsage(currentNode); break; default: return;