From f8fa6b21c25aa9c10c7e7c9bfeb90ce7d63fdaf0 Mon Sep 17 00:00:00 2001 From: prushfor Date: Fri, 23 Feb 2024 12:05:20 -0500 Subject: [PATCH] WIP on map-link: - fix bug in "Focus Controls" popup navigation button - closes #828 --- src/mapml/layers/MapMLLayer.js | 4 +-- test/e2e/core/focusControls.html | 35 ++++++++++++++++++++ test/e2e/core/focusControls.test.js | 24 ++++++++++++++ test/e2e/data/tiles/cbmt/query-feature.mapml | 18 ++++++++++ 4 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 test/e2e/core/focusControls.html create mode 100644 test/e2e/core/focusControls.test.js create mode 100644 test/e2e/data/tiles/cbmt/query-feature.mapml diff --git a/src/mapml/layers/MapMLLayer.js b/src/mapml/layers/MapMLLayer.js index d5c282dc1..06f33e9fc 100644 --- a/src/mapml/layers/MapMLLayer.js +++ b/src/mapml/layers/MapMLLayer.js @@ -489,10 +489,10 @@ export var MapMLLayer = L.LayerGroup.extend({ map.featureIndex._sortIndex(); map.featureIndex.currentIndex = map.featureIndex.inBoundFeatures.length - 1; - map.featureIndex.inBoundFeatures[0].path.setAttribute('tabindex', -1); + map.featureIndex.inBoundFeatures[0]?.path.setAttribute('tabindex', -1); map.featureIndex.inBoundFeatures[ map.featureIndex.currentIndex - ].path.setAttribute('tabindex', 0); + ]?.path.setAttribute('tabindex', 0); L.DomEvent.stop(e); map.closePopup(); map._controlContainer.querySelector('A:not([hidden])').focus(); diff --git a/test/e2e/core/focusControls.html b/test/e2e/core/focusControls.html new file mode 100644 index 000000000..760b59342 --- /dev/null +++ b/test/e2e/core/focusControls.html @@ -0,0 +1,35 @@ + + + + + Query Popup Navigation test + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/e2e/core/focusControls.test.js b/test/e2e/core/focusControls.test.js new file mode 100644 index 000000000..b86e821f0 --- /dev/null +++ b/test/e2e/core/focusControls.test.js @@ -0,0 +1,24 @@ +import { test, expect, chromium } from '@playwright/test'; + +test.describe('Playwright Keyboard Navigation + Query Layer Tests', () => { + let page; + let context; + test.beforeAll(async () => { + context = await chromium.launchPersistentContext(''); + page = + context.pages().find((page) => page.url() === 'about:blank') || + (await context.newPage()); + await page.goto('focusControls.html'); + await page.waitForTimeout(1000); + }); + + test.afterAll(async function () { + await context.close(); + }); + + test('Focus Controls button after query focuses the zoom in control', async () => { + await page.getByTestId('viewer').click(); + await page.getByTitle('Focus Controls').click(); + await expect(page.getByTitle('Zoom in')).toBeFocused(); + }); +}); diff --git a/test/e2e/data/tiles/cbmt/query-feature.mapml b/test/e2e/data/tiles/cbmt/query-feature.mapml new file mode 100644 index 000000000..f1b72dde5 --- /dev/null +++ b/test/e2e/data/tiles/cbmt/query-feature.mapml @@ -0,0 +1,18 @@ + + + A Feature, Returned by a Query + + + + + +

Test

+
+ + + -2826361 3009094 3788235 3009094 3788235 -3605502 -2826361 -3605502 -2826361 3009094 + + +
+
+
\ No newline at end of file