-
Notifications
You must be signed in to change notification settings - Fork 4
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
OEL-1167: Theme the content language switcher #94
Changes from 1 commit
8c6ef00
54fb4b1
4633bca
3ed54e2
ec1ab50
d2d4536
a369c61
af44289
ab65900
a58da02
e812d79
8e06e95
7f61d64
52f27eb
862198b
6bdc691
b90af4f
d6111df
d0341e0
44095f0
c956a83
bdeaf6a
7eef2e1
7e6ce8a
d7fc007
94185c9
1b27d53
7bf25c4
1586043
777b1ae
de3b993
5eaf632
bc274a4
e5b2f37
34998d5
023a770
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
|
||
declare(strict_types = 1); | ||
|
||
use Drupal\Component\Utility\Html; | ||
|
||
/** | ||
* Implements hook_preprocess_links(). | ||
*/ | ||
|
@@ -57,6 +59,9 @@ function oe_whitelabel_multilingual_preprocess_links__oe_multilingual_content_la | |
], | ||
]; | ||
} | ||
|
||
// Generate required ids. | ||
$variables['expandable_id'] = Html::getUniqueId('bcl-expandable'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if caching (render cache) could cause the same id to be used elsewhere on the same page. |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,7 @@ public function testMultilingualLanguageSwitcherBlockRendering(): void { | |
$crawler = new Crawler($html); | ||
|
||
// Make sure that content language switcher block is present. | ||
$actual = $crawler->filter('#dropdown-languages'); | ||
$actual = $crawler->filter('div.collapse.mt-3'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like to see the |
||
$this->assertCount(1, $actual); | ||
|
||
// Warning message doesn't contain the unavailable language, the translation | ||
|
@@ -154,7 +154,7 @@ public function testMultilingualLanguageSwitcherBlockRendering(): void { | |
*/ | ||
protected function assertSelectedLanguage(Crawler $crawler, string $expected): void { | ||
// The selected language link will contain a svg, so we target that. | ||
$actual = $crawler->filter('#dropdown-languages > div > a > svg')->parents()->first()->text(); | ||
$actual = $crawler->filter('div.collapse.mt-3 > div > a > svg')->parents()->first()->text(); | ||
$this->assertEquals($expected, trim($actual)); | ||
} | ||
drishu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
@@ -180,7 +180,7 @@ protected function assertUnavailableLanguage(Crawler $crawler, string $expected) | |
* The labels of the translations that should be rendered as links. | ||
*/ | ||
protected function assertTranslationLinks(Crawler $crawler, array $expected): void { | ||
$elements = $crawler->filter('#dropdown-languages > div > a'); | ||
$elements = $crawler->filter('div.collapse.mt-3 > div > a'); | ||
// Filter out the selected language. | ||
$elements = $elements->reduce(function (Crawler $crawler) { | ||
return $crawler->filter('svg')->count() === 0; | ||
|
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.
What is the scenario where this happens?
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.
Btw I was considering to suggest early return pattern here (invert the if to get rid of indentation).
But then we would have to drop the early return when we add the
$variables['expandable_id']
.This is why I prefer to use early return only in functions with a single responsibility - which is often not the case for preprocess.
So ok to keep it this way.
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.
Also if language is 'und', will the message "This page is not available in ***." make sense for all cases?
I think we should settle for something that works, we have no time to investigate all possible scenarios.
If you say you want to keep the current version, let's go with it.