Problem/Motivation
On a default installation configured with at least 2 languages, if you go to a non-existing URL, such as http://site.com/nosuchpage, the language switcher has no 'is-active' class on the current language.
The error message is displayed in the correct language, but the language switcher links do not reflect the current language.
Expected behaviour:
The language switcher link for the current language should have the 'is-active' class, in the same way as it does for existing URLs.
Steps to reproduce
Proposed resolution
TBA
Remaining tasks
Patch
Add tests
Review
Commit
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#32 | on-a-404-page-none-of-the-language-switcher-links-have-the-isactive-class-9.x-2802371.patch | 1.09 KB | manish.upadhyay |
#31 | 2802371-31.patch | 1.11 KB | k9606 |
#28 | 2802371-28.patch | 884 bytes | quietone |
Comments
Comment #2
rodrigoaguileraIt also happens when the URL has query parameters and not only to the language switcher but also for menu items that are active.
This is not nice when you use exposed filters on a view
Comment #3
Ralph7 CreditAttribution: Ralph7 commentedI'm going to solve this issue at DrupalCon Dublin 2016
Comment #4
rodrigoaguileraMaybe this other issue is relevant
Comment #5
Ralph7 CreditAttribution: Ralph7 commentedI'm trying , but for the moment i didn't found the bug, it has something to do with the data-drupal-link-system-path that is empty when we are on a 404-page.(active-link.js). I'm going to try to solve this issue next week.
Comment #6
Ralph7 CreditAttribution: Ralph7 commentedThe patch that is posted on the other issue that rodrigoaguilera posted , is also going to solve this issue, so i don't know what to do know, i've tested this patch from the other issue and it solves this problem as well.
Comment #7
rodrigoaguileraI feel the right thing to do un this case is to add this 404 situation to the other issue and then mark this issue as a duplicate of that one since there is more work in the other issue.
Comment #11
bighappyface CreditAttribution: bighappyface as a volunteer commented@rodrigoaguilera I closed #2775651 as the query parameter issue was solved in #2968541. I think this task is good for focusing on the language switcher issues on 403/404 pages.
Comment #12
Anybody--- Sorry this was nonsense. Forget it. ---
Comment #13
AnybodyComment #15
Anybody#2968541: ActiveLinkResponseFilter fails to set active link with query in non-alphabetical order solved this for 403 + 404 links. My tests are OK so I think we can close this as duplicate. When using bigpipe also mind #2982354: ActiveLinkResponseFilter is not working with BigPipe (in some browsers)
Comment #16
AnybodyComment #17
Peter Törnstrand CreditAttribution: Peter Törnstrand at Happiness commentedI am still experiencing this bug on 8.6.1. There is no
.is-active
class on any of the languages in the language switcher.Comment #18
markdatter CreditAttribution: markdatter as a volunteer commentedI am not using BigPipe and I still have this bug on 8.7.6.
Comment #19
markdatter CreditAttribution: markdatter as a volunteer commentedI tested this on a fresh install of Drupal 8.7.7 on Pantheon. None of the language links have the 'is-active' class on a 404 page.
Comment #20
nicrodgersComment #21
nicrodgersComment #28
quietone CreditAttribution: quietone at PreviousNext commentedI tested this on Drupal 10.1.x, standard install, with English, Italian and German. I was able to reproduce the problem.
I applied the latest patch at #2775651-41: No active language in language switcher for URL with query string and that does work. I do not know if it is the correct fix.
Comment #29
AnybodyThanks @quietone, for that reason I reopened the issue you linked ([#13890435]), as it doesn't seem to have been a duplicate then. We should check both issues for a solution and if it is or should be combined fix or not.
Comment #30
k9606 CreditAttribution: k9606 commentedI have a multilingual site, but my background admin page uses only one language, using '$current_language_code = $this->languageManager->getCurrentLanguage()->getId(); 'will not get the exact language, So I'll change it to '$current_language_code = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId();' , using the url to determine the language.
Comment #31
k9606 CreditAttribution: k9606 commentedfix #30
Comment #32
manish.upadhyay CreditAttribution: manish.upadhyay as a volunteer and commentedHi Everyone,
Here is the updated patch for 9.5.x.
Thanks,
Comment #34
enorm CreditAttribution: enorm as a volunteer commentedHello and thank you for your work!
One issue for drupal 9.5 and the language switcher when 403 or 404 pages:
Result of the patch #32: Only the
<a
gets the is-active class BUT for a working lang-switcher you also need the parent<li
as active!the html should look like this:
please can you have a look again at this problem for a new patch, thanks, Erich!