Skip to content

Commit e1264b8

Browse files
authored
Conditional role link (#471)
* Update links demo to include change of projection work * Add demo by Ahmad / Peter to demo folder. Clean up by moving some demos to the experiments repo, where they will be publicly usable. * Clean up demo directory a bit * Update continuous integration to only execute on pull requests, remove push * Add role='application' to FeatureGroup <g> element * Conditionally create role="link" on graphics that are wrapped with <map-a> * Change role="application" to role="button" on featureGroup, which makes more sense when announced * Add <svg role="none presentation"... so that each feature is not announced as "Graphic". * Remove obsolete comment
1 parent 12399ba commit e1264b8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/mapml/features/featureGroup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ export var FeatureGroup = L.FeatureGroup.extend({
1919
if(layers.length === 1 && firstLayer.options.link) this.options.link = firstLayer.options.link;
2020
if(this.options.link){
2121
M.Feature.prototype.attachLinkHandler.call(this, this.options.group, this.options.link, this.options._leafletLayer);
22+
this.options.group.setAttribute('role', 'link');
2223
} else {
2324
this.options.group.setAttribute("aria-expanded", "false");
25+
this.options.group.setAttribute('role', 'button');
2426
this.options.onEachFeature(this.options.properties, this);
2527
this.off("click", this._openPopup);
2628
}

src/mapml/features/featureRenderer.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@
44
* @returns {*}
55
*/
66
export var FeatureRenderer = L.SVG.extend({
7+
78

9+
/**
10+
* Override method of same name from L.SVG, use the this._container property
11+
* to set up the role="none presentation" on featureGroupu container,
12+
* per this recommendation:
13+
* https://github.com/Maps4HTML/Web-Map-Custom-Element/pull/471#issuecomment-845192246
14+
* @private overrides ancestor method so that we have a _container to work with
15+
*/
16+
_initContainer: function () {
17+
// call the method we're overriding, per https://leafletjs.com/examples/extending/extending-1-classes.html#methods-of-the-parent-class
18+
// note you have to pass 'this' as the first arg
19+
L.SVG.prototype._initContainer.call(this);
20+
// knowing that the previous method call creates the this._container, we
21+
// access it and set the role="none presetation" which suppresses the
22+
// announcement of "Graphic" on each feature focus.
23+
this._container.setAttribute('role', 'none presentation');
24+
},
25+
826
/**
927
* Creates all the appropriate path elements for a M.Feature
1028
* @param {M.Feature} layer - The M.Feature that needs paths generated

0 commit comments

Comments
 (0)