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

[Question] React-leaflet does not let react-modal close on first click #1103

Open
7 tasks done
18anandn opened this issue Oct 20, 2023 · 2 comments
Open
7 tasks done

Comments

@18anandn
Copy link

18anandn commented Oct 20, 2023

Bug report in v4

  • All peer dependencies are installed: React, ReactDOM and Leaflet.
  • Using the latest version of React and ReactDOM v18.
  • Using the supported version of Leaflet (v1.8.0 minimum) and its corresponding CSS file is loaded.
  • Using the latest v4 version of React-Leaflet.
  • The issue has not already been reported.
  • Make sure you have followed the quick start guide for Leaflet.
  • Make sure you have fully read the documentation and that you understand the limitations.

Expected behavior

After clicking on the zoom button, modal closes when clicked on overlay on first click.

Actual behavior

After clicking on the zoom button, modal does not close when clicked on overlay on first click. It takes 2 clicks. It works as expected with every other interaction (like click inside modal content or map, scroll zoom).

Steps to reproduce

Dependencies:
{ "leaflet": "^1.9.4", "react": "^18.2.0", "react-dom": "^18.2.0", "react-leaflet": "^4.2.1", "react-modal": "^3.16.1" }

Code to reproduce:
`
import { useState } from 'react';
import ReactModal from 'react-modal';
import { MapContainer } from 'react-leaflet/MapContainer';
import { TileLayer } from 'react-leaflet/TileLayer';

function App() {
const [isOpenModal, setIsOpenModal] = useState(false);

const handleClick = () => {
setIsOpenModal(true);
};

return (
<>
Open React Leaflet
<ReactModal
isOpen={isOpenModal}
onRequestClose={() => setIsOpenModal(false)}
parentSelector={() => document.body}
>
<MapContainer
center={[51.505, -0.09]}
zoom={13}
scrollWheelZoom={false}
style={{
height: '50dvh',
width: '50dvw',
}}
>



</>
);
}

export default App;
`

@cowglow
Copy link

cowglow commented Oct 27, 2023

When you say the Zoom button, do you mean from the map controls? Because there isn't anything in your code snippet that would trigger that behavior. You might want to use the useMapEvent and listen for the end of the Zoom to trigger the stage change for the modal to close.

@18anandn
Copy link
Author

When you say the Zoom button, do you mean from the map controls? Because there isn't anything in your code snippet that would trigger that behavior. You might want to use the useMapEvent and listen for the end of the Zoom to trigger the stage change for the modal to close.

@cowglow

Yes I mean the zoom button provided by react-leaflet by default. If I use touchpad or keyboard (ctrl and +) to zoom then this problem does not arise.

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