joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.74k stars 3.64k forks source link

Language Switcher not Accessible (Lighthouse going from 100% to 84% as soon as Module is published) #37479

Closed woluweb closed 2 years ago

woluweb commented 2 years ago

Steps to reproduce the issue

On a J4.1 website, publish a Language Switcher. languageswitcher

Expected result

Lighthouse > accessibility was 100% and should stay 100%.

Actual result

Lighthouse > accessibility goes down to 84%

See detail & screenshot hereafter:

simbus82 commented 2 years ago

I can confirm the Lighthouse problem with Joomla 4.1.2. But, about the "Tables and lists" problem (missing UL or OL), i think it's a detection problem. I see this code generated in my 4.1.2 website with the standard mod_languages:

<div class="mod-languages">
  <ul class="lang-inline">
    <li dir="ltr">
      <a href="#it">IT</a>
    </li>
    <li class="lang-active" dir="ltr">
      <a href="#en">EN</a>
    </li>
  </ul>
</div>
woluweb commented 2 years ago

I forgot to mention explicitely:

  1. I am using Cassiopeia
  2. the generated HTML is the following
<div class="mod-languages">
    <p class="visually-hidden" id="language_picker_des_195">
        Sélectionnez votre langue
    </p>

    <ul role="listbox" aria-labelledby="language_picker_des_195" class="mod-languages__list lang-inline">
        <li class="lang-active">
            <a aria-current="true" role="option" aria-label="Français (FR)" href="https://www.mydomainname.com/fr/">
                FR
            </a>
        </li>
        <li>
            <a role="option" aria-label="English (UK)" href="/en/"> EN </a>
        </li>
        <li>
            <a role="option" aria-label="Nederlands" href="/nl/"> NL </a>
        </li>
    </ul>
</div>
dgrammatiko commented 2 years ago

Remove the role="option" A link should not change it's role (unless someone is doing it on purpose. Also it should be wrapped in a nav element as it is essential navigation and last the role="listbox" is also wrong

drmenzelit commented 2 years ago

What about this solution: https://russmaxdesign.github.io/language-switcher/

brianteeman commented 2 years ago

And how would that work if you have 4 or more languages

drmenzelit commented 2 years ago

I don't understand the question... We have 2 options now: dropdown or horizontal list. I'm talking of replacing the horizontal list with the radio buttons. It is semantically correct and the user can navigate through the option with the arrow keys, what is correct. Making keyboard navigation inside the list is much more complicated: https://w3c.github.io/aria-practices/#kbd_general_within

But it is only a suggestion I found as reading more about this topic.

brianteeman commented 2 years ago

@dgrammatiko is correct about the role being incorrect. please test #37483

simbus82 commented 2 years ago

I don't understand the question... We have 2 options now: dropdown or horizontal list. I'm talking of replacing the horizontal list with the radio buttons. It is semantically correct and the user can navigate through the option with the arrow keys.

Just to clarify in case anyone thinks about these things ...This is really wrong for a website frontend. The "language" switcher must renders links with a real URL that can be indexable by search engine, or will break the whole multilanguage SEO, bacause you loose destination urls to the other languages. A "language switch" is not a UI interaction like in an APP or in "admin backend", but it's a navigation to a new url. Google says "Consider adding hyperlinks to other language versions of a page" in the SEO guidelines. (in fact we no longer use language dropdown on SEO and UX driven websites, it is an anachronistic thing)

brianteeman commented 2 years ago

The current markup is fine - just the additional roles that were added that is wrong. #37483 corrects that

drmenzelit commented 2 years ago

@simbus82 thank you for the explanation, you are right, I didn't take the links in account... doing too much things at the same time is not a good idea ;-)

drmenzelit commented 2 years ago

Closing as we have a PR #37483