New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an "ARIA label" field to the navigation module #7209
base: 5.x
Are you sure you want to change the base?
Conversation
I feel like this option should be available in many languages. I've had a project that focuses on an accessible navigation and I used translations for 5 different languages. If people would want to change it, they wouldn't need the field but could override the translation, wdyt? |
@zoglo you can use the |
I was just thinking about pre-delivery of the Aria-labels within translations so people don't need to set it up manually, they could still override it within this module 🤔. Maybe it's good the way it's implemented in the PR, especially for other types of navigations.. Going the long way of creating the language files for the label insert tag would just need a proper documentation. |
What do you want to do to pre-deliver here? The label will be be different for each navigation module. |
You are right, you already convinced me :D |
Having to create multiple modules just to change the label is quite inconvenient indeed. The |
But you already have to do that with several modules anyway - especially the navigation module. For example:
In each case you typically create another module - the root page dependent module selector - and then integrate that module in your page layout or a page's content. |
That's why I proposed having a fallback translation in place when the aria label is not set. If people would want it to be more accessible, they could use the new field you introduced in this PR. However, idk if it makes things worse or better because it would be so universal. |
It would make things worse in my opinion. If you have multiple modules on your site - e.g. the main menu in your header and a footer menu in your footer, they would both just say |
@@ -1,6 +1,6 @@ | |||
|
|||
<!-- indexer::stop --> | |||
<nav class="<?= $this->class ?> block"<?= $this->cssID ?><?php if ($this->style): ?> style="<?= $this->style ?>"<?php endif; ?>> | |||
<nav class="<?= $this->class ?> block"<?= $this->cssID ?><?php if ($this->style): ?> style="<?= $this->style ?>"<?php endif; ?><?php if ($this->ariaLabel): ?> aria-label="<?= $this->ariaLabel ?>"<?php endif; ?>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<nav class="<?= $this->class ?> block"<?= $this->cssID ?><?php if ($this->style): ?> style="<?= $this->style ?>"<?php endif; ?><?php if ($this->ariaLabel): ?> aria-label="<?= $this->ariaLabel ?>"<?php endif; ?>> | |
<nav<?= $this->attr($this->cssID)->addClass((string) $this->class)->addStyle((string) $this->style)->setIfExists('aria-label', $this->ariaLabel) ?>> |
@leofeyer wdyt? Should we do it like that for all templates, now that we have $this->attr()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, why not. Do we need a ->setIfExists('id', $this->???)
instead of $this->cssID
as well then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the $this->???
is the problem :). The CSS ID is currently not available in the template. Only the string including the attribute (i.e. ' id="foobar"'
). We could introduce a rawCssID
variable or something and pass $cssID[0]
to that variable in various places, so that we can use ->setIfExists('id', $this->rawCssID)
.
Another option would be to use:
$this->attr($this->cssID)->…
This should automatically parse the id="..."
string and add it as an attribute (if applicable). (haven't tested this though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be nice if it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested it - it does work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->attr()…->mergeWith($this->cssID)
would also work, JFI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer passing it to attr()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #7218
That’s right, the label must never be "menu" or "navigation", because screen readers already announce the element type. It would read "menu navigation" or "navigation navigation". The label should just be "main" or "top". |
Yes, because you change the module configuration → valid case. But if the configuration remains the same and only the label changes → not a valid case. At least in my opinion. |
It doesn't really matter what type of field you have to change. If you have 3 languages and 3 footer navigations (where the footer navigation is represented by one parent page in the site structure) you have to clone the navigation module 3 times and change one field accordingly. The rest of the configuration stays the same. And regardless: all the fields of a module are part of its configuration, not just specific fields. |
In #7218 I noticed that we already have a hardcoded |
Implements #6977