localgovdrupal / localgov_directories

Searchable, filterable, directories of information, and locations.
1 stars 3 forks source link

If an geofield map is in a vertical (or other) tab, then it doesn't load properly unless you resize the screen. #265

Open markconroy opened 1 year ago

markconroy commented 1 year ago

This is what we currently have:

Screenshot 2023-02-15 at 16 51 11

This is what we want to have: Screenshot 2023-02-15 at 16 51 25

andybroomfield commented 1 year ago

I'm not replicating this issue, is this Gin or Claro or a different admin theme? Is it using the localgov_geo module that has the map in the popup, or embedding a location field directly into the node edit form? Just to make sure if it is an issue, we fix it in the right place. If it does effect other forms, then maybe the localgov_admin_theme_improvements module would be a better place for the fix?

ekes commented 1 year ago

It's embedding the map into the form rather than in a modal. We had this issue before and it was basically fixed by moving to having the geobrowser modal in place of the inline form.

ekes commented 1 year ago

There are a host of issues on drupal.org about this:

https://www.drupal.org/project/leaflet/issues/2845418 https://www.drupal.org/project/leaflet/issues/3103941 https://www.drupal.org/project/leaflet/issues/3155885 https://www.drupal.org/project/leaflet/issues/1916924 and it's a general problem https://stackoverflow.com/questions/36246815/data-toggle-tab-does-not-download-leaflet-map https://stackoverflow.com/questions/56364129/vue2-leaflet-map-not-showing-properly-in-boostrapvue-modal/56364130

Basically comes down to the render happening too soon, before the position of the map being calculated. The solution is always refreshing the map after its position is finalised - somehow - and this is either theme/page specific, or requires a timeout to wait x ms (which seems real guesswork brittle)

ekes commented 1 year ago

We had this issue before and it was basically fixed by moving to having the geobrowser modal in place of the inline form.

It would be interesting to know the motivation to reverting to inline forms? It does restrict the ability to re-use existing locations; [I have a vague recollection that the inline entity form it needs to use is deprecated? Although I guess that depends on exactly how it's configured. EDIT: this was related to accessing the entity browser via inline entity form in a D10 site].

ekes commented 1 year ago

Conditions:-

ekes commented 1 year ago

So I've got as far as generalizing it pretty radically: https://www.drupal.org/project/geofield_map/issues/3087072#comment-14926247

Basically that JS wherever we end up putting it looks out for the map becoming visible in the viewport and then kicks the resize.

markconroy commented 1 year ago

I think we can close this issue, since it's being worked on in a Drupal.org issue instead. @ekes are you okay with us closing this?