Skip to content

Conditional role link #471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/mapml/features/featureGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export var FeatureGroup = L.FeatureGroup.extend({
if(layers.length === 1 && firstLayer.options.link) this.options.link = firstLayer.options.link;
if(this.options.link){
M.Feature.prototype.attachLinkHandler.call(this, this.options.group, this.options.link, this.options._leafletLayer);
this.options.group.setAttribute('role', 'link');
} else {
this.options.group.setAttribute("aria-expanded", "false");
this.options.group.setAttribute('role', 'button');
this.options.onEachFeature(this.options.properties, this);
this.off("click", this._openPopup);
}
Expand Down
18 changes: 18 additions & 0 deletions src/mapml/features/featureRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,25 @@
* @returns {*}
*/
export var FeatureRenderer = L.SVG.extend({


/**
* Override method of same name from L.SVG, use the this._container property
* to set up the role="none presentation" on featureGroupu container,
* per this recommendation:
* https://github.com/Maps4HTML/Web-Map-Custom-Element/pull/471#issuecomment-845192246
* @private overrides ancestor method so that we have a _container to work with
*/
_initContainer: function () {
// call the method we're overriding, per https://leafletjs.com/examples/extending/extending-1-classes.html#methods-of-the-parent-class
// note you have to pass 'this' as the first arg
L.SVG.prototype._initContainer.call(this);
// knowing that the previous method call creates the this._container, we
// access it and set the role="none presetation" which suppresses the
// announcement of "Graphic" on each feature focus.
this._container.setAttribute('role', 'none presentation');
},

/**
* Creates all the appropriate path elements for a M.Feature
* @param {M.Feature} layer - The M.Feature that needs paths generated
Expand Down