Skip to content

Commit fc89112

Browse files
authored
Remove map_height/map_width variables and inline CSS block (#401)
1 parent d60da44 commit fc89112

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

CHANGES

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
CHANGELOG
33
=========
44

5-
0.32.1 (unreleased)
5+
0.33.0 (unreleased)
66
-------------------
77

88
- CSP: Don't test nonce for truthiness before inclusion #393
99
- Solve broken marker image paths in the admin panel #392
10+
- `map_width` and `map_height` are no longer supported in LeafletWidget `attrs`,
11+
use traditional CSS to dimension maps (you can target the class
12+
`.leaflet-container-default` for example.)
1013

1114
0.32.0 (2025-05-14)
1215
-------------------

docs/widget.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ To show a textarea input for the raw GeoJSON geometry, override admin ``form_fie
9393
from django.contrib.gis.db import models as geo_models
9494

9595
LEAFLET_WIDGET_ATTRS = {
96-
'map_height': '500px',
97-
'map_width': '100%',
9896
'display_raw': 'true',
9997
'map_srid': 4326,
10098
}

leaflet/templates/leaflet/widget.html

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
{{ FORCE_IMAGE_PATH|json_script:"force-img-path" }}
55
{{ reset_view_icon|json_script:"Control-ResetView-ICON" }}
66

7-
<style nonce="{{ csp_nonce }}">
8-
{% block map_css %}
9-
{% if map_width and map_height %}#{{ id_map }} { width: {{ map_width|unlocalize }}; height: {{ map_height|unlocalize }}; }{% endif %}
10-
{% if not display_raw %}#{{ id_css }} { display: none; }{% endif %}
11-
{% endblock map_css %}
12-
</style>
13-
147
<script nonce="{{ csp_nonce }}">
158
{% block vars %}var {{ module }} = {};
169
{{ module }}.fieldid = '{{ id_css }}';
@@ -53,4 +46,4 @@
5346
target="_blank"
5447
rel="nofollow">valid GeoJSON Geometry</a>:</p>
5548
{% endif %}
56-
<textarea id="{{ id_css }}" class="required django-leaflet-raw-textarea {{ class }}" cols="150" rows="10" name="{{ name }}">{{ serialized }}</textarea>
49+
<textarea id="{{ id_css }}" class="required django-leaflet-raw-textarea {{ class }}" cols="150" rows="10" name="{{ name }}"{% if not display_raw %} hidden{% endif %}>{{ serialized }}</textarea>

leaflet/tests/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def test_default_parameters(self):
227227
self.assertIn(".fieldid = 'geom'", output)
228228
self.assertIn(".srid = 4326", output)
229229
self.assertIn(".geom_type = 'Geometry'", output)
230-
self.assertIn('#geom { display: none; }', output)
230+
self.assertIn('name="geom" hidden', output)
231231
self.assertIn('function geom_map_callback(map, options)', output)
232232

233233
def test_overriden_parameters(self):
@@ -237,7 +237,7 @@ class PolygonWidget(LeafletWidget):
237237
output = widget.render('geometry', '', {'id': 'geometry'})
238238
self.assertIn(".fieldid = 'geometry'", output)
239239
self.assertIn(".geom_type = 'Polygon'", output)
240-
self.assertIn('#geometry { display: none; }', output)
240+
self.assertIn('name="geometry" hidden', output)
241241
self.assertIn('function geometry_map_callback(map, options)', output)
242242

243243
def test_javascript_safe_callback_name(self):

0 commit comments

Comments
 (0)