From 66bbde1acfdab42f6c47fba36b7602079b6b88bd Mon Sep 17 00:00:00 2001 From: Tommy Feldt Date: Tue, 13 May 2025 17:07:24 +0200 Subject: [PATCH 1/2] Fix bug where keyboard mode would not immediately trigger, plus small modification to screen reader text --- src/assets/js/keyboard-mode.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/assets/js/keyboard-mode.js b/src/assets/js/keyboard-mode.js index 50eadab..96079bc 100644 --- a/src/assets/js/keyboard-mode.js +++ b/src/assets/js/keyboard-mode.js @@ -413,10 +413,9 @@ function updateVisibleCountries(zoom) { // Lets start keyboard mode KEYBOARD_MODE_ACTIVE = true; displayKeyboardModeMessage(); - // TODO: Find a working way to only announce this once if (!hasAnnounced) { - announcer.announce("Keyboard mode active! Press L to hear the list of countries. Press A to turn on audio feedback.") + announcer.announce("Keyboard mode active! Press L to hear the list of countries.") hasAnnounced = true; } @@ -505,10 +504,8 @@ function assignNumbersToCountries() { // Update the announcement functions to only include country count when keyboard mode is active function getAnnouncementText(baseText) { if (KEYBOARD_MODE_ACTIVE) { - const audioFeedbackState = window.auditoryFeedback && window.auditoryFeedback.isEnabled() - ? "turn off" - : "turn on"; - return `${baseText}. ${getVisibleCountriesSummary()}. Press A to ${audioFeedbackState} audio feedback.`; + const audioFeedbackIsEnabled = window.auditoryFeedback && window.auditoryFeedback.isEnabled(); + return `${baseText}. ${getVisibleCountriesSummary()}. ${audioFeedbackIsEnabled ? "Press A to turn off audio feedback." : ""}`; } return baseText; } @@ -668,7 +665,9 @@ function getAnnouncementText(baseText) { e.preventDefault(); move(t, s, false, true); - getVisibleCountries(); + // Update visible countries and keyboard mode + updateVisibleCountries(zoom); + // Update announcement to include country count only when keyboard mode is active setTimeout(() => { const baseMessage = `Zoom ${e.key === '+' ? "in" : "out"} level ${parseInt(newScale)}`; From 305b93430bcabdaa3f03f4ba58c08d67a4a0ee5d Mon Sep 17 00:00:00 2001 From: Tommy Feldt Date: Tue, 13 May 2025 17:09:48 +0200 Subject: [PATCH 2/2] Update size of the visibility box to identify more countries --- src/assets/js/keyboard-mode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assets/js/keyboard-mode.js b/src/assets/js/keyboard-mode.js index 96079bc..760fc6f 100644 --- a/src/assets/js/keyboard-mode.js +++ b/src/assets/js/keyboard-mode.js @@ -205,8 +205,8 @@ function isInViewport(element) { const rect = element.getBoundingClientRect(); // Define the dimensions of the rectangle - const rectangleWidth = 400; - const rectangleHeight = 400; + const rectangleWidth = 500; + const rectangleHeight = 500; // Calculate the position of the rectangle const rectangleLeft = (window.innerWidth - rectangleWidth) / 2;