Skip to content
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

Fix tooltip focus listener if getElement is no function #8890

Merged
merged 6 commits into from May 16, 2023

Conversation

Falke-Design
Copy link
Member

If a LayerGroup contains other layers without the getElement() function (for example another layergroup), it will throw an error, because it loops over all layers in the LayerGroup:

_addFocusListeners() {
if (this.getElement) {
this._addFocusListenersOnLayer(this);
} else if (this.eachLayer) {
this.eachLayer(this._addFocusListenersOnLayer, this);
}
},

Another solution (and I think the cleaner one) would be to loop over all layers and calling _addFocusListeners instead of _addFocusListenersOnLayer. But I'm a little bit scared about endless recursion.

 _addFocusListeners() { 
 	if (this.getElement) { 
 		this._addFocusListenersOnLayer(this); 
 	} else if (this.eachLayer) { 
 		this.eachLayer(this._addFocusListeners, this);  // <-- into _addFocusListeners instead of _addFocusListenersOnLayer
 	} 
 }, 

This fix needs to be cherry-picked into v1

@Falke-Design Falke-Design added the blocker Critical issue or PR that must be resolved before the next release label Mar 22, 2023
@Falke-Design Falke-Design added this to the 1.9.x milestone Mar 22, 2023
@Falke-Design
Copy link
Member Author

@jonkoops @mourner @IvanSanchez please review, I would like to release a new 1.9 version soon.

@Falke-Design Falke-Design merged commit de57e98 into Leaflet:main May 16, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Critical issue or PR that must be resolved before the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants