Skip to content

Commit 1ccf354

Browse files
committed
Change github tests to ignore featureIndexOverlay, run playwright
directly at the command prompt, hopefully. Delete to do list, tracked on PR notes WIP on getting featureIndexOverlay to behave Add localized message to feature index output for 'No features found' Remove commented code Remove unused / uncovered code, add comments. Update _handleLink to focus map when finished handling, so that the feature index shows up again (if enabled). Ensure feature index and reticle displayed after reload Ensure feature index and reticle displayed before and after fullscreen Upgrade playwright Add tests for feature index and reticle display after fullscreen, history navigation, link activation. De-flake a test that got really bad post-upgrade of playwright Remove layerchange layeradd layerremove overlayremove events from feature index handlers; the index and reticle display on map focus, disappear when focus moves off map. This seems a bit odd when adding or removing layers, but it is simple, and reticle returns with focus. Update GeolocationButton to focus the map after it locates the user. Update geolocation tests to adapt to changes. Add feature index tests for after reload, fullscreen, history nav, geolocation activation, Add test feature index presence post-geolocation activation, deactivation, and link following actions Formatting by prettier Split up slow test Make feature index overlay responsive to map width Change x client from npx to npm for ci testing
1 parent 19f46ee commit 1ccf354

18 files changed

+368
-205
lines changed

package-lock.json

Lines changed: 77 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
}
3333
],
3434
"scripts": {
35-
"test": "npx playwright test --grep-invert='featureIndexOverlay.*'",
35+
"test": "npx playwright test --retries=3",
3636
"jest": "jest --verbose --noStackTrace"
3737
},
3838
"devDependencies": {

src/mapml-viewer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,7 @@ export class MapViewer extends HTMLElement {
11181118
this._traversalCall = 1;
11191119
this._map.panBy([initialLocation.x - curr.x, initialLocation.y - curr.y]);
11201120
}
1121+
this._map.getContainer().focus();
11211122
}
11221123

11231124
_toggleFullScreen() {

src/mapml.css

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
left: 45px;
5252
}
5353
}
54-
54+
5555
/* Generic class for seamless buttons */
5656
.mapml-button {
5757
background-color: transparent;
@@ -909,7 +909,16 @@ label.mapml-layer-item-toggle {
909909
width: 450px;
910910
font-size: 16px;
911911
}
912-
912+
@container leafletmap (max-width: 650px ) {
913+
.mapml-feature-index {
914+
width: 70cqw;
915+
}
916+
}
917+
@container leafletmap (max-width: 390px ) {
918+
.mapml-feature-index {
919+
bottom: 100px;
920+
}
921+
}
913922
.mapml-feature-index-content > span{
914923
width: 140px;
915924
white-space: nowrap;

src/mapml/control/FullscreenButton.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ L.Map.include({
8484
this._enablePseudoFullscreen(container);
8585
}
8686
}
87+
this.getContainer().focus();
8788
},
8889

8990
_enablePseudoFullscreen: function (container) {

src/mapml/control/GeolocationButton.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,28 @@ export var GeolocationButton = L.Control.extend({
44
},
55

66
onAdd: function (map) {
7-
this.locateControl = L.control
8-
.locate({
9-
showPopup: false,
10-
strings: {
11-
title: M.options.locale.btnLocTrackOff
12-
},
13-
position: this.options.position,
14-
locateOptions: {
15-
maxZoom: 16
16-
}
17-
})
18-
.addTo(map);
7+
// customize locate control to focus map after start/stop, so that
8+
// featureIndexOverlay is correctly displayed
9+
L.Control.CustomLocate = L.Control.Locate.extend({
10+
start: function () {
11+
L.Control.Locate.prototype.start.call(this);
12+
map.getContainer().focus();
13+
},
14+
stop: function () {
15+
L.Control.Locate.prototype.stop.call(this);
16+
map.getContainer().focus();
17+
}
18+
});
19+
this.locateControl = new L.Control.CustomLocate({
20+
showPopup: false,
21+
strings: {
22+
title: M.options.locale.btnLocTrackOff
23+
},
24+
position: this.options.position,
25+
locateOptions: {
26+
maxZoom: 16
27+
}
28+
}).addTo(map);
1929

2030
var container = this.locateControl._container;
2131
var button = this.locateControl;

src/mapml/layers/FeatureIndexOverlay.js

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ export var FeatureIndexOverlay = L.Layer.extend({
2424
);
2525
this._body.index = 0;
2626
this._output.initialFocus = false;
27-
map.on(
28-
'layerchange layeradd layerremove overlayremove',
29-
this._toggleEvents,
30-
this
31-
);
27+
map.on('focus blur popupclose', this._addOrRemoveFeatureIndex, this);
3228
map.on('moveend focus templatedfeatureslayeradd', this._checkOverlap, this);
3329
map.on('keydown', this._onKeyDown, this);
3430
this._addOrRemoveFeatureIndex();
@@ -77,6 +73,8 @@ export var FeatureIndexOverlay = L.Layer.extend({
7773
let index = 1;
7874
let keys = Object.keys(features);
7975
let body = this._body;
76+
let noFeaturesMessage = document.createElement('span');
77+
noFeaturesMessage.innerHTML = M.options.locale.fIndexNoFeatures;
8078

8179
body.innerHTML = '';
8280
body.index = 0;
@@ -123,6 +121,9 @@ export var FeatureIndexOverlay = L.Layer.extend({
123121
}
124122
});
125123
this._addToggleKeys();
124+
if (index === 1) {
125+
body.appendChild(noFeaturesMessage);
126+
}
126127
},
127128

128129
_updateOutput: function (label, index, key) {
@@ -189,16 +190,7 @@ export var FeatureIndexOverlay = L.Layer.extend({
189190
}
190191
},
191192

192-
_toggleEvents: function () {
193-
this._map.on(
194-
'viewreset move moveend focus blur popupclose',
195-
this._addOrRemoveFeatureIndex,
196-
this
197-
);
198-
},
199-
200193
_addOrRemoveFeatureIndex: function (e) {
201-
let features = this._body.allFeatures ? this._body.allFeatures.length : 0;
202194
//Toggle aria-hidden attribute so screen reader rereads the feature index on focus
203195
if (!this._output.initialFocus) {
204196
this._output.setAttribute('aria-hidden', 'true');
@@ -214,26 +206,24 @@ export var FeatureIndexOverlay = L.Layer.extend({
214206
this._output.popupClosed = true;
215207
} else if (e && e.type === 'focus') {
216208
this._container.removeAttribute('hidden');
217-
if (features !== 0)
218-
this._output.classList.remove('mapml-screen-reader-output');
219-
} else if (e && e.originalEvent && e.originalEvent.type === 'pointermove') {
220-
this._container.setAttribute('hidden', '');
221-
this._output.classList.add('mapml-screen-reader-output');
209+
this._output.classList.remove('mapml-screen-reader-output');
210+
// this is a very subtle branch. The event that gets handled below is a blur
211+
// event, which happens to have the e.target._popup property
212+
// when there will be a popup. Because blur gets handled here, it doesn't
213+
// get handled in the next else if block, which would hide both the reticle
214+
// and the index menu, and then recursively call this method with no event
215+
// argument, which manipulates the aria-hidden attribute on the output
216+
// in order to have the screenreader read its contents when the focus returns
217+
// to (what exactly???).
222218
} else if (e && e.target._popup) {
223219
this._container.setAttribute('hidden', '');
224220
} else if (e && e.type === 'blur') {
225221
this._container.setAttribute('hidden', '');
226222
this._output.classList.add('mapml-screen-reader-output');
227223
this._output.initialFocus = false;
228224
this._addOrRemoveFeatureIndex();
229-
} else if (this._map.isFocused && e) {
230-
this._container.removeAttribute('hidden');
231-
if (features !== 0) {
232-
this._output.classList.remove('mapml-screen-reader-output');
233-
} else {
234-
this._output.classList.add('mapml-screen-reader-output');
235-
}
236225
} else {
226+
// this is the default block, called when no event is passed (recursive call)
237227
this._container.setAttribute('hidden', '');
238228
this._output.classList.add('mapml-screen-reader-output');
239229
}

src/mapml/layers/MapMLLayer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,6 +2017,7 @@ export var MapMLLayer = L.Layer.extend({
20172017
e.preventDefault();
20182018
featureEl.zoomTo();
20192019
featureEl._map.closePopup();
2020+
featureEl._map.getContainer().focus();
20202021
};
20212022
// we found that the popupopen event is fired as many times as there
20222023
// are layers on the map (<layer-> elements / MapMLLayers that is).

0 commit comments

Comments
 (0)