nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 699 forks source link

Popup class needs classList in addition to className #1723

Open arthur-clifford opened 2 years ago

arthur-clifford commented 2 years ago

I have a marker with a popup and when I had the popup open and moved the map, the popup disappered. This is a new behavior for something that had been working in previous releases.

It ended up being that I was defining the className option for popup like "my-class hidden" where hidden is a class I use for hiding elements with display:none. Even though I removed the hidden class programmatically, when the map moved or zoomed the className was getting re-applied and the ui for the marker has class="my-class hidden". (which took me a bit to realize).

The reason I was doing this was because I wanted to add the popup ui before populating it and I want it to be hidden until I'm ready to show it (populated with content). I'm not showing a popup on click of a feature but to show results of a query, so I"m moving one marker around and hiding it when it is dismissed.

I was probably abusing className in the first place. But in order to accomplish what I was attempting it would be nice to have the ability to provide a classList option in addition to className so that I can have a set of classes I can add to the popup element and so you can reapply className.

For className and classList it would be good to have a method for changing the options after popup initialization.

And for that matter, it would be nice to be able to have a domNode or element getter that would allow getting a reference tot he html element the popup is referring to without having to roll my own getElementsByClassName routine on the className.