Closed (fixed)
Project:
Drupal core
Version:
8.3.x-dev
Component:
Classy theme
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Dec 2015 at 12:53 UTC
Updated:
8 May 2017 at 02:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
gnugetHi!
The file indeed exists you can find it at:
core/themes/classy/css/components/image-widget.cssUPDATE: ohh you are right, the image-widget is not declared in the classy.libraries.yml, so this seems a bug.
Comment #3
gnugetThis how image-preview looks right now:
And this is how it looks adding the library in the classy.library.yml file:
And I attach a patch with the code for add this library in the classy.library.yml file.
Thanks!
Comment #4
hass commentedI'm confused... first you said
This is still true after your patch? Why are you now adding a CSS file to
classy/base? This still does not fix the attaching inimage-widget.html.twig!? Maybe the proper fix is this?[classy.libraries.yml]
Comment #5
hass commentedComment #6
gnugetTrue, I was confused about how the libraries thing work, #5 looks great :-)
Comment #7
hass commentedNow it works as intended... thanks for great hint and brainstorming.
Can you RTBC this patch, please?
Comment #8
gnugetComment #9
hass commentedComment #11
catchCommitted/pushed to 8.1.x, thanks!
While this is a straight bugfix, it's potentially a visual change for a subtheme of classy, so I don't think it can go into a patch release.
Comment #12
hass commentedThis means we need to wait 6 months to get bugs fixed in D8? Really?
Please commit to 8.0, too.
Comment #13
catchIf we were going to fix this in 8.0;x, I'd remove the dead CSS (or move it to Seven) and the reference in the template, then there's no change for subclassing themes.
I think that's the right fix in general so reverted from 8.1.x for now.
Comment #15
gnugetIn this patch I moved the library to seven and removed the reference from classy
Comment #16
hass commentedNope. Why has this rolled back for 8.1 now? The fix was correct. Moving the file does not fix the classy and other themes. Please leave the old fix in.
I only asked why we need to wait for such a bugfix 6 months to a release. All classy based themes are affected, but this could be noted in release notes and we are done, too. This patch does not break anything - it just fixed a visual bug. If there is a classy based theme it may has already overridden this styles or just ignored it. Nothing to worry.
Now thats going too far.
Comment #17
davidhernandezThis can break themes because CSS that was mistakenly not included before is now suddenly included. If someone added their own CSS to account for it, that will suddenly cause a problem. It would likely be slight, but still.
I could also argue that since it creates any visual change, and would go in 8.1, that it could have a change record.
Comment #18
gnugetAgree with #17 and even also agree with 13 any of those approach is good to me.
Comment #19
joelpittetDepending on the visual bugs this may cause I'd keep it in 8.0.x and let the committer decide. Probably just needs to go into Bartik as well but I think #15 patch is going in the right direction for this fix.
Comment #20
star-szrComment #21
gnugetAnd 8.1 is almost out and this fix is not part of the core :-/
I will move it to "needs review" again at this point doesn't matter if should go at 8.1 or 8.0
Comment #23
gnugetMoving to 8.2.x because 8.1.x is out and this introduce a little visual change, also I updated the issue Summary.
Comment #24
gnugetComment #25
gnugetComment #26
dinarcon commentedThe patch at number at #15 needed reroll. I have done that and tested it. It looks good. Thanks @gnuget!
Without patch:

With patch:

Comment #27
dinarcon commentedThe tests have passed. Marking as RTBC.
Comment #28
davidhernandezPlease don't rtbc your own patches. Someone else will need to review it.
Comment #29
dinarcon commentedHi @davidhernandez. I just did the reroll. Since no code changes were made and I tested the patch I thought it was ok to mark the issued RTBC. I was not aware I could not mark the issue RTBC in such a case. Thanks for setting it back to needs review.
Comment #30
omers commentedThe reroll on #26 works fine :)
Comment #31
star-szrThanks, a couple points:
I think we should probably just leave this file and potentially just add a comment to say that it's not being loaded by Classy. Someone could be referencing this from their theme, maybe even fixing the bug in their own theme. I think that is possible but I might be wrong.
Indentation in this file looks off, 4 spaces instead of 2. It should have the same indentation as Classy's image-widget.html.twig.
Comment #32
dinarcon commentedThanks for your review @Cottser. The new patch also attaches the 'seven/image-widget' library from image-widget.html.twig as the Classy template did.
Comment #33
chernous_dn commentedTest patch #32 , works fine. attach screenshots.
Comment #34
chernous_dn commentedComment #35
wim leersThis is very unsatisfactory. We should at least say why it is not being loaded, and therefore why this file then still exists.
This is identical to Classy's template!
This should therefore use
{% extends … %}, and just do the{{ attach_library(…) }}.Comment #37
gnugetHi! Wim Leers
Thanks for your review!
2. We cannot use
{% extends .. %}because as far as I know with extends we must overwrite a theme parent block and classy'simage-widget.html.twigtemplate have none of those, I tried using theusekeyword instead ofextendsbut I got this error:wig_Error_Runtime: Template "@classy/content-edit/image-widget.html.twig" cannot be used as a traitSo I'm not sure how to do this without copy/pasting the entire template and adding there the library.
miss I something?
Thanks!
Comment #38
wim leersYou don't need to use Twig blocks at all. You can do things like:
Comment #39
chernous_dn commentedHi, Wim Leers.
But we dont have in seven
image.html.twig, we need createimage.html.twig. Or you mean include from another place?Comment #40
wim leersThat was just an example. Here, it would be:
core/themes/seven/templates/content-edit/image-widget.html.twigwould contain:Comment #41
chernous_dn commentedI think best solution, use #5 patch. Just include
image-widget.cssin classy. Classyсomponents works in seven too. And we dont need move to seven additional files.
Comment #42
gnugetHi @Wim Leers.
I already tried what you suggested (I just did it again just to make sure) and this is the error I got:
I investigated that error and I found out to this error is related to what I mentioned at #37 I think your example at #38 is working because doesn't print anything in the
image.html.twigtheme but not sure.[update] I tried using
{% set something %}and yes the error is gone so the problem is when we try to print something outside of a block I don't think the{% extends %}approach is gonna work for this particular case. :(Comment #43
wim leersMy bad. This is what that should look like:
Comment #44
gnugetSorry for being a pain.
I tried what you suggested and I got a new error:
Twig_Error_Syntax: Unknown "attach_library" tag in "core/themes/seven/templates/content-edit/image-widget.html.twig" at line 14. in Twig_Parser->subparse() (line 178 of vendor/twig/twig/lib/Twig/Parser.php).And checking the documentation https://www.drupal.org/developing/api/8/assets
It seems to actually we must use
{{ extends }}instead of{% extends %}thanks for all your help and time.
David.
Comment #45
gnugetAnd while Wim Leers doesn't be happy with the fix this still will need work.
Comment #46
chernous_dn commented{% extends %}andattach_librarydont work together in one filecore\themes\seven\templates\content-edit\image-widget.html.twigSo I decided includeimage-widget.cssin classy theme. And add in seven dependence from classy.Comment #47
davidhernandezIf the only thing in the template is the extends line, then there is no need for the template. I'm wondering why the attach_library didn't work there. We should figure that out.
Comment #48
gnugetHi @Chernous_dn
The initial bug is to the image-widget.css is missing in the classy theme, the approach to you took at #46 was already explorer at #5, We didn't committed this approach because:
The alternative suggested at #31 is:
Hi David.
What do you mean with the attach_library didn't work there?
Comment #49
davidhernandezHe said in #46 they didn't work in the same file.
Comment #50
gnugetI explained why at: #37.
Thanks for your time on this :-)
Comment #51
davidhernandezWe can do more in an extended template than override a parent block. A block is needed for overriding the parent html content, and other content related things. If the attach_library is indeed not working in an extended template, we may need to investigate why. That sounds like a bug.
Comment #52
gnugetDo you mean the
extendsneed to be wrapped up in a{{...}}instead of{%...%}?Sorry, I don't understand the problem yet, but if you think it is a bug would be great if you create a follow up explaining the problem and I will do my best trying to provide a fix/patch
Thanks!
Comment #53
davidhernandezAck, ok. I see. attach_library is a function not a tag, so it can't be executed directly.
...I don't like the idea of modifying the parent template to make this work so it looks like #32 was actually correct.
Comment #54
gnugetIn that case, we just need to fix 35.1 and this should be ready to go. :-D
Comment #55
chernous_dn commentedHi @gnuget,
Thanks for the explanation.
Comment #56
gnugetUpdating the summary of the ticket and adding the novice tag.
Comment #57
gnugetComment #58
gnugetComment #59
mohit_aghera commentedUpdating comment in patch #32
Comment #60
gnugetHi @mohit_aghera.
Sorry the message is not enough, we need to explain WHY that CSS file is in the classy theme but is not used, I'm not a native speaker but we need something like:
Comment #61
mohit_aghera commentedHi @gnuget
It's fine. I've updated message as per your suggestion. Please have a look at it.
Comment #62
wim leers+1
+1
-1
This is absolutely unacceptable.
This is a bug in Twig, because it definitely is intended to work this way — they even fixed a bug related to this some time ago: https://github.com/twigphp/Twig/issues/426. This is why I'm so confused about this not working. It really should work.Actually, it works fine. See #2387069-47: {% extends "foo.html.twig" %} in Twig templates does not respect theme inheritance + #2387069-48: {% extends "foo.html.twig" %} in Twig templates does not respect theme inheritance, which also use this.Actually, both of those are wrong: they're for
set(), not for custom functions. There's several similar issues in Twig's issue queue: https://github.com/twigphp/Twig/search?q=A+template+that+extends+another....I think the answer could be simpler in the mean time: let Seven's
image-widget.html.twigdo this:Comment #63
chernous_dn commentedUse #61 and #62 comment. Create patch.
Comment #64
gnugetHi Chernous_dn
Here you are doing exactly the same as #32 (repeating a file in a different theme).
I just attached a new version of the patch fixing this problem.
Comment #67
gnugetComment #69
wim leersLooks good now, with the exception of the comment IMO still being confusing:
Here's my suggestion:
Comment #70
gnugetI just updated the comment with your suggestion.
Thanks!
Comment #71
wim leersThanks! I think it's ready now. Cottser should be the one to commit this. Also curious to hear what @davidhernandez thinks.
Comment #72
star-szrThis looks much better than the last time I saw it, interesting use of
includeas well - I'm assuming someone has tested that :)@davidhernandez what do you think about this approach?
Comment #73
xjmNR for @davidhernandez' feedback, because I almost compulsively assigned this to @Cottser which would not have helped. :)
Comment #74
hass commented9 months, 73 comments of useless discussion for one line of change that fixes a serious interface bug.
Are you all totally crazy? What a waste of time. I think we have more importants issues to fix and my first patch should simply get committed.
Comment #75
hass commentedComment #76
gnugetIt was committed but you complained about it and was reverted.
But that let us work in a better fix so thank you :-)
Comment #77
hass commentedNo, I only complained that it was not committed to 8.0 and not in general about the commit. In reaction to just this question it was reverted and we still waiting a year later, 80 comments later and tons of hours waste of time only to get this into mainline without any good change to the original fix. You will only add another bullsh** fix that requires again a lot of work in D9. Great job and the issue is still not fixed.
We better change the rule that stable is allowed to receive BUGFIXES.
Comment #78
davidhernandez@hass, feel free to spend your time on something else you feel is less of a waste. Participation here is not compulsory. There is no reason to be riled by a bug lkie this. It is easily fixable on a project.
Looking now.
Comment #79
davidhernandez1) What we have lost with this bug is the floating of the thumbnail, compacting that area. So it's good to keep this CSS and encourage its use, but it is not functionally critical. It's good to fix that in Seven.
2) The comment is fine. I didn't poor over it, but everyone else seems happy with it.
3) Classy is frozen, but this is fine to remove since it does not function and it does not alter markup.
4) The alignment of the image and form needs fixing. I'm not sure if I would recommend doing that in the Classy CSS or just Seven, but that can be handled in a follow up issue. It is not the result of this issue, but this bug is probably why it wasn't noticed before release.

5) I hadn't noticed this before, but is there a reason why this was put into a subfolder in Seven? Seven doesn't use subfolders for any other templates. If there is no reason for it, this file should be in the main folder.
6) Classy should be capitalized in this comment.
7) Not the fault of this issue, but we ended up with a blank line at the the top of the file, no @file comment, and no blank line before the rules begin. I'm not clear if we required @file in CSS as a rule, but this is consistent in all the other Classy CSS files. We should fix that while we're here.
Functionally, everything looks fine. The solution works. 5, 6, and 7 are my only issues. They are simple corrections. If those are resolved/clarified, the solution is RTBC to me.
Comment #80
gnugetHi! davidhernandez
Here a patch with 5,6 and 7 fixed.
Thanks!
Comment #81
davidhernandezI hate being pedantic, but can you add the blank line after the comment to be consistent with the other CSS files?
Comment #82
joelpittetDid you mean wrap to 80 characters or am I missing a standard that you mentioned in #81 @davidhernandez?
Comment #83
davidhernandezNo, I meant the blank line after the comment and before the first set of rules. I don't know if we standardized it, but Classy's other CSS files are consistent with that.
Comment #84
darketaine commentedAdded the blank line between comments and first code line in all files needed
Comment #85
darketaine commentedTaking also into account the 80 chars limit
Comment #86
darketaine commentedOk, removed the break line from twig files (my bad) and made the comment more readable (thanks @davidhernandez)
Sorry for the noise :/
Comment #87
davidhernandezThanks!
Comment #88
xjmBack to @Cottser then. Thanks all.
Comment #90
star-szrLooks good, thanks for the additional tweaks @darketaine @joelpittet @gnuget!
I made one minor change on commit and that was to move the library declaration higher up to preserve our beautifully alphabetized classy.libraries.yml, hope nobody objects. Interdiff attached to show that change.
Committed ae16101 and pushed to 8.3.x. Thanks!
Comment #91
wim leersNice attention to detail! :D
Comment #92
davidhernandezCan't believe I missed that. :( Thanks, Cottser!
Comment #94
danquah commentedDid that followup issue mentioned in 4) in #79 ever get created? We just have a customer reporting the suddenly floating image as a bug and it took quite a while to track the cause back to this issue, would probably have gone a bit faster if it had been tracked by an issue.
(I'll happily create the issue, just no point in make a duplicate if it has already been done)
Comment #95
gnugetAs far as I know, the follow-up was never created. please feel free to do it.
Thanks!