diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-09-19 12:50:05 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-09-19 12:51:11 +0800 |
commit | 0d1534532d1056f7275c5ca03da486a4acccaa0f (patch) | |
tree | a0d5390814dcaccd04cfb9c7aacb380c9eb21b2b | |
parent | 7e1dcca489ecc0489734d4fee12315998fc67c12 (diff) |
fix: do not change focus map when it is alone
-rw-r--r-- | src/dumbymap.mjs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 5800351..0b42144 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs | |||
@@ -288,12 +288,13 @@ export const generateMaps = async (container, callback) => { | |||
288 | container.setAttribute("data-layout", nextLayout) | 288 | container.setAttribute("data-layout", nextLayout) |
289 | } | 289 | } |
290 | 290 | ||
291 | // Use Tab to change focus map | ||
291 | if (event.key === 'Tab') { | 292 | if (event.key === 'Tab') { |
292 | e.preventDefault() | 293 | e.preventDefault() |
293 | 294 | ||
294 | const selector = '.map-container, [data-placeholder]' | 295 | const selector = '.map-container, [data-placeholder]' |
295 | const candidates = Array.from(htmlHolder.querySelectorAll(selector)) | 296 | const candidates = Array.from(htmlHolder.querySelectorAll(selector)) |
296 | if (candidates.length === 0) return | 297 | if (candidates.length <= 1) return |
297 | 298 | ||
298 | const currentFocus = htmlHolder.querySelector('.map-container[data-focus=true]') | 299 | const currentFocus = htmlHolder.querySelector('.map-container[data-focus=true]') |
299 | ?? htmlHolder.querySelector('[data-placeholder]') | 300 | ?? htmlHolder.querySelector('[data-placeholder]') |