Skip to content

Adds ability to wrap geometry subtypes with span and a elements + a element functionality within coordinates #383

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 18 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix single feature behavior
  • Loading branch information
ahmadayubi committed Apr 7, 2021
commit ae3561d2d069b2f5448f75aa1b169a9585e80100
24 changes: 14 additions & 10 deletions src/mapml/features/featureGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ export var FeatureGroup = L.FeatureGroup.extend({
this.options.group.setAttribute("aria-expanded", "false");
this.options.group.setAttribute('tabindex', '0');
L.DomUtil.addClass(this.options.group, "leaflet-interactive");
if(!this.options.link && layers.length > 1) {
L.DomEvent.on(this.options.group, "keyup keydown mousedown", this._handleFocus, this);
let firstLayer = layers[Object.keys(layers)[0]];
if(layers.length === 1 && firstLayer.options.link){ //if it's the only layer and it has a link, take it's link
this.options.link = firstLayer.options.link;
this.options.linkTarget = firstLayer.options.linkTarget;
this.options.linkType = firstLayer.options.linkType;
}
if(this.options.link){
M.Feature.prototype.attachLinkHandler.call(this, this.options.group, this.options.link, this.options.linkTarget, this.options.linkType, this.options._leafletLayer);
} else {
this.options.onEachFeature(this.options.properties, this);
L.DomEvent.on(this.options.group, "keyup keydown mousedown", this._handleFocus, this);
this.off("click", this._openPopup);
} else {
if(layers.length === 1){
let singleLayer = layers[Object.keys(layers)[0]];
M.Feature.prototype.attachLinkHandler.call(this, this.options.group, singleLayer.options.link, singleLayer.options.linkTarget, singleLayer.options.linkType, this.options._leafletLayer);
} else
M.Feature.prototype.attachLinkHandler.call(this, this.options.group, this.options.link, this.options.linkTarget, this.options.linkType, this.options._leafletLayer);
}
}

Expand All @@ -42,9 +44,11 @@ export var FeatureGroup = L.FeatureGroup.extend({
if((e.keyCode === 9 || e.keyCode === 16 || e.keyCode === 13) && e.type === "keyup") {
this.openTooltip();
} else if (e.keyCode === 13 || e.keyCode === 32){
L.DomEvent.stop(e);
this.closeTooltip();
this.openPopup();
if(!this.options.link && this.options.onEachFeature){
L.DomEvent.stop(e);
this.openPopup();
}
} else {
this.closeTooltip();
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/core/featureLinks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jest.setTimeout(50000);
() => {
beforeAll(async () => {
browser = await playwright[browserType].launch({
headless: false,//ISHEADLESS,
headless: ISHEADLESS,
slowMo: 50,
});
context = await browser.newContext();
Expand Down