View | Details | Raw Unified | Return to bug 39209
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/js/cookieconsent.js (-1 / +24 lines)
Lines 71-82 Link Here
71
        const consentBar = $("#cookieConsentBar");
71
        const consentBar = $("#cookieConsentBar");
72
        consentBar.attr("aria-hidden", "false");
72
        consentBar.attr("aria-hidden", "false");
73
        consentBar.css("display", "flex");
73
        consentBar.css("display", "flex");
74
75
        // Set focus to the first focusable element within the consent bar
76
        const firstFocusableElement = consentBar
77
            .find("a, button, input, select, textarea")
78
            .filter(":visible")
79
            .first();
80
        if (firstFocusableElement.length) {
81
            firstFocusableElement.focus();
82
        } else {
83
            // If no focusable elements exist, add tabindex to the bar itself to make it focusable
84
            consentBar.attr("tabindex", "-1").focus();
85
        }
74
    }
86
    }
75
87
76
    function hideConsentBar() {
88
    function hideConsentBar() {
77
        const consentBar = $("#cookieConsentBar");
89
        const consentBar = $("#cookieConsentBar");
78
        consentBar.attr("aria-hidden", "true");
90
        consentBar.attr("aria-hidden", "true");
79
        consentBar.hide();
91
        consentBar.hide();
92
93
        // Remove focus from any currently focused element
94
        if (document.activeElement) {
95
            document.activeElement.blur();
96
        }
97
98
        // Set focus to the body, which effectively removes visible focus indicators
99
        // This allows the first Tab press to highlight the "Skip to main content" link
100
        document.body.focus();
101
        document.querySelector("body").setAttribute("tabindex", "-1");
102
        document.querySelector("body").focus();
103
        document.querySelector("body").removeAttribute("tabindex");
80
    }
104
    }
81
105
82
    // Hides the appropriate consent container, depending on what
106
    // Hides the appropriate consent container, depending on what
83
- 

Return to bug 39209