en a tab is shown
    $('.nav-tabs a').on('shown.bs.tab', function (e) {
        clearPreviousAnchor(); // Clear any previous anchors before switching tabs
        var tabName = $(e.target).attr('data-tab-name');
        var parentTabPane = $(e.target).closest('.tab-content').prev('.nav-tabs').find('.nav-link.active').attr('data-tab-name');
        var url = new URL(window.location.href);

        if (parentTabPane) {
            url.searchParams.set('tab', parentTabPane);
            url.searchParams.set('