Problem/Motivation
If you visit the /admin
page, the tag contains a path-admin
class, but if you visit the page in another language, like /fa/admin
, the tag will contain a path-fa
class and miss the path-admin
class, because it uses the first segment after the /
symbol (in core/includes/theme.inc -> function template_preprocess_html
).
The .path-admin
class is now used in a few CSS rules, which means those styles won't be applied if the path has a language prefix.
Proposed resolution
Construct that CSS class based on a non-aliased, non-processed path.
Remaining tasks
Commit.
User interface changes
CSS classes applied to path-admin will work again. Bartik has these styles:
$ git grep path-admin
core/themes/bartik/css/components/admin.css:.path-admin #content img {
core/themes/bartik/css/components/admin.css:.path-admin #content .simpletest-image img {
core/themes/bartik/css/components/admin.css:.path-admin #admin-dblog img {
API changes
None.
Comments
Comment #1
dileepmaurya CreditAttribution: dileepmaurya commentedComment #3
dileepmaurya CreditAttribution: dileepmaurya commentedComment #4
Gábor HojtsyI don't think that is a good idea, there may be any number of other things done to the path, eg. path aliases. Does this prefix work with a path alias a /headquarters for /admin for example?
Comment #5
dileepmaurya CreditAttribution: dileepmaurya commentedComment #6
dileepmaurya CreditAttribution: dileepmaurya commentedComment #7
gvsoI think we shouldn't use drupal_is_front_page() in order to avoid make this patch again https://www.drupal.org/node/2388627
Comment #8
dileepmaurya CreditAttribution: dileepmaurya commenteddrupal_is_front_page() is replaced with \Drupal::service('path.matcher')->isFrontPage()
Comment #9
Gábor HojtsyI cannot tell if this is technically correct or not, but it looks promising.
Please watch your code style, you should indent with 2 spaces, not 3 or 4. Also add space after if, else and before {.
Also not sure how best we can test this but it sure would be great to have test for this, since it was broken unnoticed.
Comment #10
dileepmaurya CreditAttribution: dileepmaurya commentedFormating code.
Comment #11
dileepmaurya CreditAttribution: dileepmaurya commentedComment #12
Gábor HojtsyCode format looks good :) Given the change is in the theme system this can get tests AFAIS.
Comment #13
Gábor HojtsyComment #14
Kristen PolI tested the patch and it does indeed work as expected so then time for tests. :)
Comment #15
Kristen PolMoving back to needs work.
Comment #16
dileepmaurya CreditAttribution: dileepmaurya commentedIf any one on admin page what classes sholud be added ?
I think if we visit on admin page then one of the class should be path-admin and its not depend on url language prefix or any type of prefix and url alias.
Comment #17
dileepmaurya CreditAttribution: dileepmaurya commentedAdding language specific class in body such as lang-[language-id].
Comment #18
dileepmaurya CreditAttribution: dileepmaurya commentedComment #19
dileepmaurya CreditAttribution: dileepmaurya commentedComment #20
Gábor HojtsyThe root HTML tag already has a lang="XY" attribute. That can already perfectly used in CSS. No need for that body class. Also not in scope for this issue anyway.
@dileepmaurya: please also post interdiffs (https://www.drupal.org/documentation/git/interdiff) so we can review what did you change and explain changes. Updated patches like 19 without comments and interdiffs is very hard to review.
Comment #21
segi CreditAttribution: segi commentedComment #22
Gábor HojtsyComment #23
prajaankit CreditAttribution: prajaankit commented#20
Comment #24
prajaankit CreditAttribution: prajaankit commentedComment #25
Gábor Hojtsy@prajaankit:
1. Please respect if an issue was assigned to someone recently.
2. You did not post an explanation or an interdiff of what you changed.
3. You did not actually address anything in #20, despite referring to that only in your comment.
Comment #26
segi CreditAttribution: segi commentedI modified the last #23 patch based on @Gábor Hojtsy feedbacks, I created a new test and I add it to LanguageSwitchingTest test class.
Comment #27
Gábor HojtsyLooking good now, only two notes:
You don't use this anymore.
I would also test this without the French language, to compare it also works the same on the non-foreign page.
Comment #29
segi CreditAttribution: segi commentedOk, I fixed the patch based on feedbacks.
Comment #30
segi CreditAttribution: segi commentedComment #31
Gábor HojtsyRetitled to be more specific. Also updated issue summary. Thanks!
Comment #32
DevElCuy CreditAttribution: DevElCuy commentedComment #33
DevElCuy CreditAttribution: DevElCuy commentedRemoved SprintWeekend2015Queue by mistake.
Comment #34
alexpottNeeds a reroll
Comment #35
alexpottActually I didn't commit the patch that causes the conflict.
Comment #36
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed f8aa6c2 and pushed to 8.0.x. Thanks!
We need to be careful not to change filemodes. Fixed on commit.
Comment #38
Gábor HojtsyYay superb, thanks all!
Comment #39
davidhernandezNot sure what happened with the patches, but there was back and forth with root_path being set TRUE or FALSE and html.html.twig being modified or not modified. In the end that seems to have gotten confused because path-frontpage doesn't work now with that logic.
The template uses
not root_path
so the preprocess functions should set it FALSE.Comment #40
Gábor HojtsyHow does the test work then?
Comment #41
davidhernandezThe test in this issue? It looks to only be visiting admin pages, and looking for 'path-admin'. The switch in logic only affected the class for the frontpage.
Comment #42
idebr CreditAttribution: idebr commentedI opened a followup for the missing body class: #2411597: Class 'path-frontpage' missing from <body>