Skip to content

Commit 14d222a

Browse files
committed
bug #2035 [Map][Leaflet] Fix Popup's automatic-content (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- [Map][Leaflet] Fix Popup's automatic-content | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Leaflet's Popup does not have `headerContent`, but GoogleMaps does. To prevent too many issues when developpers change for another Map Bridge, with Simon we took the decision to render `headerContent` and `content` data in Leaflet Popup's content. But it looks like I've did things wrong, if I don't specify `headerContent`, then a `null` text is displayed in the popup: <img width="460" alt="Capture d’écran 2024-08-08 à 14 01 11" src="https://github.com/user-attachments/assets/c88e6c91-7ff6-4c40-8642-abbc9f1883fe"> Because in JavaScript, `null + 'foo'` gives `nullfoo` :( <img width="1692" alt="Capture d’écran 2024-08-08 à 14 04 29" src="https://github.com/user-attachments/assets/2caf390c-d05c-4e16-93e1-3d865201e7a7"> With this PR, the popup is now nicely displayed: <img width="409" alt="Capture d’écran 2024-08-08 à 14 08 14" src="https://github.com/user-attachments/assets/0da41c34-9afd-4441-8350-892461f59796"> Commits ------- 33fce10 [Map][Leaflet] Fix Popup's automatic-content
2 parents 108fc68 + 33fce10 commit 14d222a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Map/src/Bridge/Leaflet/assets/dist/map_controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class map_controller extends AbstractMapController {
3535
}
3636
doCreateInfoWindow({ definition, marker, }) {
3737
const { headerContent, content, rawOptions = {}, ...otherOptions } = definition;
38-
marker.bindPopup(`${headerContent}<br>${content}`, { ...otherOptions, ...rawOptions });
38+
marker.bindPopup([headerContent, content].filter((x) => x).join('<br>'), { ...otherOptions, ...rawOptions });
3939
if (definition.opened) {
4040
marker.openPopup();
4141
}

src/Map/src/Bridge/Leaflet/assets/src/map_controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default class extends AbstractMapController<
7171
}): Popup {
7272
const { headerContent, content, rawOptions = {}, ...otherOptions } = definition;
7373

74-
marker.bindPopup(`${headerContent}<br>${content}`, { ...otherOptions, ...rawOptions });
74+
marker.bindPopup([headerContent, content].filter((x) => x).join('<br>'), { ...otherOptions, ...rawOptions });
7575
if (definition.opened) {
7676
marker.openPopup();
7777
}

0 commit comments

Comments
 (0)