diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 265de2403c..bba4ba5cbc 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,6 +6,7 @@ Changelog * Maintenance: Update djhtml (html formatting) library to v 1.5.2 (Loveth Omokaro) * Maintenance: Re-enable `strictPropertyInitialization` in tsconfig (Thibaud Colas) +* Maintenance: Refactor accessibility checker userbar item (Albina Starykova) 4.2 (xx.xx.xxxx) - IN DEVELOPMENT diff --git a/client/scss/components/_userbar.scss b/client/scss/components/_userbar.scss index 8dd9063a5c..08237bf68d 100644 --- a/client/scss/components/_userbar.scss +++ b/client/scss/components/_userbar.scss @@ -234,6 +234,10 @@ $positions: ( margin-inline-end: 0.5em; fill: currentColor; } + + .w-a11y-result__count { + margin-inline-end: theme('spacing.2'); + } } .w-icon { @@ -286,17 +290,25 @@ $positions: ( max-height: 60vh; } + .w-dialog__header { + display: flex; + align-items: center; + justify-content: space-between; + } + .w-dialog__title { @apply w-h3; padding: theme('spacing.4') theme('spacing.5'); + margin-bottom: 0; } .w-dialog__subtitle { @apply w-body-text; - padding-inline-start: theme('spacing.5'); + padding-inline-end: theme('spacing.5'); display: flex; align-items: center; gap: theme('spacing.2'); + margin-bottom: 0; } .w-a11y-result__row { @@ -363,8 +375,8 @@ $positions: ( } .w-a11y-result__count { - margin-inline-end: theme('spacing.2'); display: flex; + flex-shrink: 0; justify-content: center; align-items: center; background-color: theme('colors.positive.100'); diff --git a/client/src/entrypoints/admin/userbar.js b/client/src/entrypoints/admin/userbar.js index 73e2847396..acb7e6a295 100644 --- a/client/src/entrypoints/admin/userbar.js +++ b/client/src/entrypoints/admin/userbar.js @@ -322,8 +322,10 @@ class Userbar extends HTMLElement { this.trigger.appendChild(a11yErrorBadge); } - const dialogtemplates = document.querySelectorAll('[data-wagtail-dialog]'); - const dialogs = dialog(dialogtemplates, this.shadowRoot); + const dialogTemplates = this.shadowRoot.querySelectorAll( + '[data-wagtail-dialog]', + ); + const dialogs = dialog(dialogTemplates, this.shadowRoot); if (!dialogs.length) { return; @@ -340,13 +342,6 @@ class Userbar extends HTMLElement { '#w-a11y-result-selector-template', ); - const modalErrorBadge = document.createElement('span'); - modalErrorBadge.setAttribute('data-a11y-result-count', ''); - modalErrorBadge.classList.add('w-a11y-result__count'); - const headerElement = modal.$el.querySelector('.w-dialog__subtitle'); - headerElement.appendChild(modalErrorBadge); - - // Solution for future refactoring to move badges to Django template const innerErrorBadges = this.shadowRoot.querySelectorAll( '[data-a11y-result-count]', ); @@ -403,13 +398,14 @@ class Userbar extends HTMLElement { const currentA11ySelectorText = currentA11ySelector.querySelector( '[data-a11y-result-selector-text]', ); + const selectorName = node.target[0]; // Remove unnecessary details before displaying selectors to the user - currentA11ySelectorText.textContent = `${node.target}`.replace( + currentA11ySelectorText.textContent = selectorName.replace( /\[data-block-key="\w{5}"\]/, '', ); currentA11ySelector.addEventListener('click', () => { - const inaccessibleElement = document.querySelector(node.target); + const inaccessibleElement = document.querySelector(selectorName); inaccessibleElement.style.scrollMargin = '6.25rem'; inaccessibleElement.scrollIntoView({ behavior: 'smooth', diff --git a/docs/releases/4.2.md b/docs/releases/4.2.md index 0d8f8d5faa..d142d1a841 100644 --- a/docs/releases/4.2.md +++ b/docs/releases/4.2.md @@ -199,6 +199,7 @@ This feature was developed by Matt Westcott, and sponsored by [YouGov](https://y * Add deprecation warnings for `wagtail.core` and other imports deprecated in Wagtail 3.0 (Matt Westcott) * Upgraded Transifex configuration to v3 (Loic Teixeira) * Replace repeated HTML `avatar` component with a template tag include `{% avatar ... %}` throughout the admin interface (Aman Pandey) + * Refactor accessibility checker userbar item (Albina Starykova) ## Upgrade considerations diff --git a/wagtail/admin/templates/wagtailadmin/shared/dialog/dialog.html b/wagtail/admin/templates/wagtailadmin/shared/dialog/dialog.html index 583eece992..b652793197 100644 --- a/wagtail/admin/templates/wagtailadmin/shared/dialog/dialog.html +++ b/wagtail/admin/templates/wagtailadmin/shared/dialog/dialog.html @@ -29,14 +29,16 @@ {% endif %}
{{ subtitle }}
- {% endif %} + {% if subtitle %} +{{ subtitle }}
+ {% endif %} +