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

Button onClick function in editable popup content doesn't work #10

Open
ariello87 opened this issue Mar 1, 2022 · 5 comments
Open

Button onClick function in editable popup content doesn't work #10

ariello87 opened this issue Mar 1, 2022 · 5 comments

Comments

@ariello87
Copy link

I'm trying to put a button on editable popup content.
The button appears, but onClick function wasn't fired.

import popup from "react-leaflet-editable-popup"
..
<popup>
    <button
                    onClick={e=>{
                        onClickFunc()
                    }}
     >Simple button</button>
</popup> 
@ariello87 ariello87 changed the title Using button in editable popup content Button onClick function in editable popup content doesn't work Mar 1, 2022
@slutske22
Copy link
Owner

This seems to be problem with react-leaflet itself, rather than the plugin. See here: PaulLeCam/react-leaflet#11

There have been a few discussions about workarounds:
https://stackoverflow.com/questions/42894803/rendering-react-components-inside-popup-of-react-leaflet-draw-drawn-layer-on-rea

https://stackoverflow.com/questions/67460092/need-proper-way-to-render-jsx-component-inside-leaflet-popup-when-using-geojson

Does this work as expected with a regular react-leaflet popup?

@ariello87
Copy link
Author

For rect-leaflet it works:

function onClickFunc() { console.log("onClickFunc"); } return ( <Popup> <button onClick={e => { onClickFunc() }} >Simple button</button> </Popup>

@slutske22
Copy link
Owner

If you wouldn't mind creating a reproducible example with a codesandbox, that would help me debug this

@ariello87
Copy link
Author

Hi,
here you can find the codesandbox with the example:

https://codesandbox.io/s/reverent-currying-c0v70g?file=/src/App.js

@slutske22
Copy link
Owner

Can you please fix the CSS, I am not able to compare the regular react-leaflet popup with the popup from this plugin:

Screen Shot 2022-03-02 at 7 26 06 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants