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

Add Panel broken for Typescript (Temp fix included) #25

Closed
ghost opened this issue Dec 10, 2018 · 3 comments
Closed

Add Panel broken for Typescript (Temp fix included) #25

ghost opened this issue Dec 10, 2018 · 3 comments
Labels

Comments

@ghost
Copy link

ghost commented Dec 10, 2018

Hello! I have found an issue with Typescript support in the latest version. It boils down to an extra letter (or maybe one less than enough?)

In the vanilla module when you add a panel you set the 'pane' field, yet in the Typescript definition it is the 'panel' field. This would cause the panel to load without the content.

I was able to fix the issue by modifying your leaflet-sidebar.js class. The relevant change was data.pane to data.panel.

// Create pane node

if (data.panel)

{

if (typeof  data.panel  ===  'string')

{

// pane is given as HTML string

pane  =  L.DomUtil.create('DIV', 'leaflet-sidebar-pane', this._paneContainer);

content  =  '';

if (data.title)

content  +=  '<h1 class="leaflet-sidebar-header">'  +  data.title;

if (this.options.closeButton)

content  +=  '<span class="leaflet-sidebar-close"><i class="fa fa-caret-left"></i></span>';

if (data.title)

content  +=  '</h1>';

pane.innerHTML  =  content  +  data.panel;

} else

{

// pane is given as DOM object

pane  =  data.panel;

this._paneContainer.appendChild(pane);

}

pane.id  =  data.id;

Hope this helps!

@noerw
Copy link
Owner

noerw commented Dec 10, 2018

Hi, thank you for the heads up!

Instead of your proposed fix I'd rather fix the typescript definition from panel to pane.
The actual JS implementation is authoritative, as most users are relying on it, including our examples and documentation.

@noerw noerw closed this as completed in f0beaf9 Dec 10, 2018
@noerw
Copy link
Owner

noerw commented Dec 10, 2018

The fix is in now in the latest release 3.0.4. Let me know if it does not work for you

@ghost
Copy link
Author

ghost commented Dec 10, 2018

Works great, thanks a ton!

@noerw noerw added the bug label Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant