Skip to content

Commit 52b9ccb

Browse files
committed
fix: rewrite QGIS BS4 tab attributes to BS5 before inserting popup HTML
QGIS Server generates data-toggle="tab" (Bootstrap 4 syntax). Bootstrap 5's data-API only responds to data-bs-toggle="tab", so tabs were never activated. Replace the attribute in the HTML string before DOM insertion; Bootstrap 5 then handles tab switching natively, and the manual event-listener workaround is no longer needed.
1 parent 6cb4e5a commit 52b9ccb

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

assets/src/legacy/map.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,10 @@ window.lizMap = function() {
844844

845845
var eventLonLatInfo = map.getLonLatFromPixel(xy);
846846

847+
// QGIS Server generates Bootstrap 4 data-toggle="tab"; rewrite to Bootstrap 5 syntax
848+
// so the native data-API handles tab switching without custom event listeners.
849+
text = text.replace(/data-toggle="tab"/g, 'data-bs-toggle="tab"');
850+
847851
var popup = null;
848852
var popupContainerId = null;
849853
if( 'popupLocation' in config.options && config.options.popupLocation != 'map' ){
@@ -900,28 +904,9 @@ window.lizMap = function() {
900904
lizMap.mainLizmap.popup.mapPopup.setPosition([eventLonLatInfo.lon, eventLonLatInfo.lat]);
901905
}
902906

903-
document.getElementById('liz_layer_popup_contentDiv')
904-
.querySelectorAll('a[data-toggle="tab"]')
905-
.forEach(el => {
906-
el.addEventListener('click', e => {
907-
e.preventDefault();
908-
bootstrap.Tab.getOrCreateInstance(el).show();
909-
});
910-
});
911907
}
912908
lastLonLatInfo = eventLonLatInfo;
913909

914-
// Activate tabs in dock popup (popupcontent)
915-
if (popupContainerId) {
916-
document.querySelectorAll('#' + popupContainerId + ' a[data-toggle="tab"]')
917-
.forEach(el => {
918-
el.addEventListener('click', e => {
919-
e.preventDefault();
920-
bootstrap.Tab.getOrCreateInstance(el).show();
921-
});
922-
});
923-
}
924-
925910
// Display related children objects
926911
addChildrenFeatureInfo( popup, popupContainerId );
927912
// Display geometries

0 commit comments

Comments
 (0)