Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
css lint errors:
Line Column Message
46 1 Don't use IDs in selectors.
49 1 Don't use IDs in selectors.
52 1 Don't use IDs in selectors.
64 5 Using width with padding-right can sometimes make elements larger than you expect.
Use the color-warning class instead of custom color styling.
Proposed resolution
change id's to selectors
Remaining tasks
User interface changes
A slight color change for the block placed state for consistency
API changes
Beta phase evaluation
Issue category | Task because coding standards |
---|---|
Issue priority | Major because ... Critical/Not critical because ... |
Unfrozen changes | Unfrozen because it only changes CSS |
Comment | File | Size | Author |
---|---|---|---|
#54 | Screen Shot 2015-05-14 at 15.02.17.jpg | 525.66 KB | LewisNyman |
#46 | 2422399-46.patch | 2.07 KB | tadityar |
#32 | block-admin-csslint-2422399-32.patch | 2.36 KB | aliyakhan |
#23 | 2422399-23.patch | 2.39 KB | rpayanm |
#27 | beforelabelchangedtostrong.png | 51.9 KB | aliyakhan |
Comments
Comment #1
joelpittetDoes it need to be in .block-form?
Comment #2
mortendk CreditAttribution: mortendk commentedComment #3
LewisNymanHey all, sorry to increase the scope of this issue but it would be nice to fix the underlying problem here instead of just changing the selector.
Instead of using #block-placed we can use the .color-warning class to reuse the colors in the Seven theme, and delete this CSS.
The reason we have this CSS is because the label element is being abused to just display a some information. If we used the strong element instead of label then we wouldn't need any CSS at all and we could delete this.
Comment #4
mortendk CreditAttribution: mortendk commentedgood catch - yup lets kill it when we see it & fix it if we can
Comment #5
aliyakhan CreditAttribution: aliyakhan commentedI've made changes as per #3. Attached a patch
Comment #6
aliyakhan CreditAttribution: aliyakhan commentedComment #12
LewisNymanAh, ok in this situation the block-placed ID is actually being used for functionality, we should keep this class to use it for functionality, by prefixing it with .js-. We would then have two classes: color-warning for styling and js-block-placed for functionality.
Changing that class has probably broken tests, I would do a search in test files for the block-placed string and replace it with js-block-placed
Comment #13
skippednote CreditAttribution: skippednote commentedRerolling #5
Comment #15
skippednote CreditAttribution: skippednote commentedJust figured it out why the tests are breaking. It's because we are changing from label to strong.
The tests use XPATH with label for the selector.
Comment #16
aliyakhan CreditAttribution: aliyakhan commented@Lewis @skippednote @mortendk How should we proceed with it now? any suggestions?
Comment #17
mortendk CreditAttribution: mortendk commented@aliyakhan we need to:
.js-
prefix, remember that we dont wanna have any visual styling on it...also selebrate that were cleaning up all the css for Drupal8 :)
Comment #18
aliyakhan CreditAttribution: aliyakhan commentedAdded a patch for js class prefixing.
Comment #19
kapildoshi CreditAttribution: kapildoshi commentedI have applied #18 patch. After applying patch, I created one custom block named "testing" and assigned it in "Footer fourth" region but found that the custom block is not draggable i.e. not able to re-position it to another region.
Please find the attached screenshot.
Comment #20
idebr CreditAttribution: idebr commented@ Kapil Doshi There is a bug in the Block module where a block is not moved to the correct region when the target region is empty. This issue is being resolved in a separate issue: #2177335: Selecting 'Disabled' does not move the block to the disabled region when there are no disabled blocks
Comment #21
idebr CreditAttribution: idebr commentedThe patch in #18 does not include the css lint fixes from #13
Comment #22
aliyakhan CreditAttribution: aliyakhan commented@idebr I'm looking into it today.
Comment #23
rpayanmTime to merge!
Comment #24
aliyakhan CreditAttribution: aliyakhan commentedLooks fine. Attaching shots
Comment #25
nuwe CreditAttribution: nuwe commentedi have tested and found the patch 2422399-23.patch resolves the issue
Comment #26
LewisNymanI ran this through CSSlint using the toolkit and I still get one error:
Comment #27
aliyakhan CreditAttribution: aliyakhan commentedFixes done :
Css Linting
Label replaced with Strong tag
JS ID replacement
Changing label to strong effect almost all labels. Shots attached
Comment #28
aliyakhan CreditAttribution: aliyakhan commentedComment #29
LewisNyman@aliyakhan I think that the label has to stay a label for accessibility reasons? Also this change would change all labels in Drupal :\ I think we should leave the element as it is and try and fix this in only CSS
Comment #31
aliyakhan CreditAttribution: aliyakhan commentedYeah doesn't make sense to modify the markup. Will update the patch again.
Comment #32
aliyakhan CreditAttribution: aliyakhan commentedOk this inludes ID to Class modifications in js and csslint fixes.
Comment #33
aliyakhan CreditAttribution: aliyakhan commentedComment #34
idebr CreditAttribution: idebr commented@aliyakhan Thanks for working on this!
In #3 @LewisNyman suggested to use the .color-warning class. However, Seven is the only theme that has a color-warning declaration. By removing this, other themes no longer have a visual cue of where the block went. Since this is a usability regression, let's just update the selector instead to the fix the lint error.
This indentation is incorrect: the Drupal coding standard dictate two spaces for indentation.
Comment #35
JCL324At Midcamp sprints, going to work on comments in #34.
Comment #36
JCL324I fixed the extra white space mentioned in #34-2. After the bot tests, this still needs more work; I will leave the css/class issues to someone more experienced with that than me as mentioned in #34-1.
Comment #37
mradcliffeIt looks like the remaining task is to use a different selector than #block-placed, but keep the background color style. The issue summary should probably be updated with remaining task and probably a beta evaluation.
Comment #38
RowboTony CreditAttribution: RowboTony commentedDisregard these comments, I took a stab at it, but I don't really know what needs to be done next. I'll just stand back, watch, and learn.
Comment #39
aliyakhan CreditAttribution: aliyakhan commentedHey Ide
I couldn't found any usability regression with other themes. color-warning class is available.Attached shots
Comment #40
LewisNymanWe don't need to make this change. The colour cue is not required for functionality, as it is still possible to see the block has moved. If colour was required then we would have an accessibility issue :) It will be communicated to admin theme maintainers that modules rely on these utility classes and they need to support them, see Changes to Drupal 8 that affect admin theme maintainers.
Also, I'm generally not fan of issues where we are only fixing CSSLint errors and ignoring other improvements, as the CSSlint errors are only supposed to be there to help us maintain the quality of the CSS. If we avoid problems that we know we have to fix then we are shooting ourselves in the foot a little.
If we agree then I think that the last patch is RTBC. I've added the beta summary evaluation.
Comment #41
joelpittetCan we just move that visual cue into classy?
Comment #42
LewisNymanWe could, but we it would overwriting the JS in Classy, we haven't done that before
Comment #43
joelpittet@LewisNyman Ah good point, well I don't think the color-warning class is needed (and is not used in this patch). I was just thinking the CSS yellow color moved to classy. I think that color-warning class doesn't need to exist in core or at all.
Not sure about this change, but maybe it can be placed in classy to preserve that color and style?
+1 to these changes.
Need @LewisNyman's opinion on this change. Seems suspect to me.
I'm happy to have this change in core.
The formatting on this is off by a bunch. Use the same syntax, it will save some grief.
$form['blocks'][$entity_id]['#attributes']['class'][] = 'color-warning';
$form['blocks'][$entity_id]['#attributes']['class'][] = 'js-placed-block';
And color-warning class IMO isn't needed.
Comment #44
LewisNymanThere is justification for it under #2336141: Create reusable color classes and Changes to Drupal 8 that affect admin theme maintainers
I don't mind moving the reuseable classes to Classy, as long as they are loaded as part of the Seven theme.
Comment #45
LewisNymanThe remaining tasks are:
Remove this change from this patch and leave the layout stuff to #2335531: Replace block placement page layout CSS with reusable layout classes
The formatting on this is off by a bunch. Use the same syntax, it will save some grief.
Comment #46
tadityar CreditAttribution: tadityar commentedRe-rolled and changed as #45 suggested.
Comment #47
joelpittetThere is no
.color-warning
class in core/stark, so adding this class only really helps the seven theme... kinda(different style background color #fdf8ed).I'd rather not do a form_alter in classy just to get this color class and it's very very close in color/intent. So I suggest we leave it here in the patch, but please add a
.color-warning { background-color: #ffd; }
class to classy theme to preserve this.But looking at classy, there is ironically no CSS in it, I'm assuming yet... So maybe we just leave .color-warning {} in
core/modules/block/css/block.admin.css
for now with that class on it?Everything else looks great.
Comment #48
LewisNymanhmm, I'm not sure. In my mind its perfectly fine to have classes in Classy that don't have styling in Classy. We're trying remove CSS that we have to override in themes, see the motivation in #2336141: Create reusable color classes
I think adding reusable color classes into Stark or Classy is a bigger discussion for another issue, because it's totally fine not to show any color if it's not required for functionality (and it shoudn't if used correctly)
Comment #49
LewisNymanI think that maybe this is the wrong issue to start moving classes or CSS into Classy in this issue, if we manage to remove custom CSS here then it's an improvement. Setting back to needs review.
Comment #51
saki007sterI ran this through CSSlint using the toolkit and I still get one error:
But according to the comment #45 this is to be left for #2335531: Replace block placement page layout CSS with reusable layout classes .
Comment #52
saki007sterComment #53
disasm CreditAttribution: disasm at AppliedTrust commentedComment #54
LewisNymanNice, I've updated the issue summary to include the colour change.
Comment #55
alexpottCommitted e82c6f2 and pushed to 8.0.x. Thanks!
thanks for adding the beta evaluation to the issue summary.