- Issue created by @flo909
- Merge request !26Issue #3539128: change h1 and h2 to divs and add corresponding class → (Open) created by flo909
- leymannx Berlin
This is a very good idea. And there's already similar issues filed to the official GitHub repo:
[Provide configurable consentModal.titleTag and consentNotice.titleTag #425]
But I guess, until this gets fixed upstream, we need to do it ourselves.
To maintain backwards compatibility we ideally also offer a new option in the simple_klaro.settings to configure the consentModal.titleTag and the consentNotice.titleTag.
But first of all we need to find a way to make it work, to get the heading markup-changing JavaScript attached at the right moment and the markup actually changed.
Later we need to get that option in.
- leymannx Berlin
Thank you! This patch is working already really, really nice as is. Very clean solution.
Now, what's left is to provide options in the Simple Klaro settings to enable this behavior or not. By default it must be switched off.
-
Update Simple Klaro settings form to provide a checkbox "Fix heading structure" with the description: "By default Klaro has the modal title as
<h2>
and the settings form title as<h1>
. This is bad for accessibility (non-sequential heading structure) and for SEO (<h2>
without parent; multiple<h1>
). With this option enabled both headings are replaced with a<div>
and its heading level as CSS class added (<div class="h2">
and<div class="h1">
). Remember you now need to take care yourself of styling it accordingly. -
Get this checkbox value passed from PHP to JS
drupalSettings
and adjust the heading JS to react only when this checkbox is enabled -
Provide an update hook that sets these values to
FALSE
initially.
-
Update Simple Klaro settings form to provide a checkbox "Fix heading structure" with the description: "By default Klaro has the modal title as
- leymannx Berlin
Uploading your current work as static patch, as this already does the job perfectly, just the new option is missing to have it disabled by default for people who don't want the heading tags changed.
- leymannx Berlin
Added the functionality to have it configurable and off by default. Let's get this tested in the wild.
- 🇫🇷France flo909 Zurich
Updated patch fixing drupalSettings undefined error in MutationObserver callbacks.
The issue was that setTimeout() wasn't passing the drupalSettings parameter
to the replaceHeadings function when the MutationObserver triggered DOM changes.