Problem/Motivation

@mortendk has said this....
".clearfix class is a layout fix that cause of its visual nature should not really be in classy - it should be added to themes that need them (ex bartik & seven) clearfix have its uses but will be forgotten when flexbox gets to be introduced to the world, it seems kinda stupid to carry that with us around."

Proposed resolution

Discuss if we should remove 'clearfix' classes from Classy.

Remaining tasks

Discuss and decide on an action

User interface changes

n/a

API changes

n/a

Data model changes

n/a

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LewisNyman’s picture

If modules are still loading CSS that floats elements, then clearfix is still useful. We don't have a good way of reusing clearfix like we would with Sass.

cdog’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
4.79 KB

The attached patch removes all occurences of the .clearfix class from Classy. To find the files where it's used you can use the following grep command:

$ grep -iRl "clearfix" ./core/themes/classy
./core/themes/classy/templates/content-edit/node-edit-form.html.twig
./core/themes/classy/templates/field/field--text.html.twig
./core/themes/classy/templates/form/field-multiple-value-form.html.twig
./core/themes/classy/templates/navigation/toolbar.html.twig
./core/themes/classy/templates/views/views-exposed-form.html.twig
./core/themes/classy/templates/views/views-view-grid.html.twig
Sam152’s picture

+++ b/core/themes/classy/templates/field/field--text.html.twig
@@ -4,16 +4,6 @@
- * A 'clearfix' class is added, because 'text' fields have a 'format' property
- * that allows a Text Format to be associated with the entered text, which then
- * applies filtering on output. A common use case is to align images to the left
- * or right, and without this 'clearfix' class, such aligned images may be
- * rendered outside of the 'text' field formatter's boundaries, and hence
- * overlap with other fields. By setting the 'clearfix' class on all 'text'
- * fields, we prevent that.

How does flexbox help in this use case? I agree with LewisNyman that clearfix still has a place for clearing non-layout related floated elements.

This particular instance is probably important for making floated image in rich text fields not break layouts.

cdog’s picture

Status: Needs review » Needs work

The last submitted patch, 2: drupal-clearfix-2544868-2.patch, failed testing.

cdog’s picture

@Sam152 Using flexbox doesn't require floats for aligning elements.

[...]the flexible box model provides an improvement over the block model in that it does not use floats[...]

See Using CSS flexible boxes for an explanation and A Complete Guide to Flexbox for a few examples.

cdog’s picture

Sam152’s picture

Although it might be possible using flexbox, core still uses floats for aligning images in filtered text:

.align-right {
    float: right;
}

Until that is addressed, blindly removing all the clearfix classes is a regression.

The last submitted patch, 2: drupal-clearfix-2544868-2.patch, failed testing.

mortendk’s picture

@sam152 .clearfix is a hack and for positioning that could just as easy be added directly to the existing selector.
The problem is that its spread all around the code & makes it harder in the end for a theme to overwrite later, when frontenders for real begins to use flexbox.

instead of adding in a clearfix class that we can't manage directly in the css later, we should add the clearfix methode to the wrapper in the css, then its manageble later from the css without having to remove the clearfix in the template.

.field--type-text:before,
.field--type-text:after {
    content: " "; 
    display: table;
}
.field--type-text:after {
    clear: both;
}
cdog’s picture

Ok, I'm just trying to give some help and also to start contributing.

@Sam152 Agreed, I've proposed an initial patch which is incomplete. It identifies the .clearfix usage and removes it from the markup (without really breaking anything on a default setup).

@mortendk Yes, this is missing from the attached patch. The micro clearfix hack should be dirrectly applied on the wrapper elements.

Are any of you at the extended sprints this weekend and interested in discussing a suitable solution?

LewisNyman’s picture

I still don't know if this is a good idea. Should we discuss it before patching?

cdog’s picture

Ok, I'm going to work on something else for now. I've seen @mortendk here at the sprints but he doesn't look very approachable :)) Just kidding, let me know if any of you are available for a discussion in the meantime. Thanks!

mortendk’s picture

@cdog aaaaaw dude you should just have come over and punched me, im sorry i had to leave early.
It might be a bit premature to try to rip it out right now 2 weeks before RC1, but its defo a thing we should look into, or figure out a name things better in the future
but that might be an issue for classy 2

cdog’s picture

@mortendk that's fine, I thought myself that's not a priority for now. As a new contributor I start to work on issues that are well defined or somehow isolated. Just le me know when this is ready for work or if there's anything else where help is needed.

nesta_’s picture

Status: Needs work » Needs review

Update issue status for #7

Status: Needs review » Needs work

The last submitted patch, 7: drupal-clearfix-2544868-7.patch, failed testing.

nesta_’s picture

Rerolled #7.

darketaine’s picture

I'm not sure if this is possible as Classy is a base theme, so it can't be changed anymore. I think that these kind of changes can only happen in non base themes (neither Classy nor Stable) at this state.

Sumit kumar’s picture

Tested patch #18 woring for me clear all clearfix class for classy theme

Sumit kumar’s picture

Issue tags: -#drupalconasia2016 ++drupalconasia2016
Sumit kumar’s picture

Issue tags: -+drupalconasia2016 +drupalconasia2016
Sumit kumar’s picture

Status: Needs review » Reviewed & tested by the community
LewisNyman’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs screenshots, +Bartik, +Seven

I'm not sure we can set this to RTBC yet. Have we had a proper discussion at yet? We are adding a lot of repetitive code to maintain, is this a good idea?

Also, we need screenshots of the affected areas to show that we didn't miss anything. How does this change affect Bartik and Seven?

emma.maria’s picture

Title: remove clearfix class from classy » Discuss removing 'clearfix' class from Classy
Version: 8.0.x-dev » 8.1.x-dev
Category: Task » Plan
Issue summary: View changes
Status: Needs review » Active
Issue tags: -Needs screenshots

Setting this to a 'Plan' as we need to discuss alternative solutions first before working on patches.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

emma.maria’s picture

Version: 8.2.x-dev » 9.x-dev
catch’s picture

Version: 9.x-dev » 8.3.x-dev

This could either happen in 8.x, or it should be won't fix, but I don't see a specific reason to move it to 9.x since the class could be moved to Stable?

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Project: Drupal core » Classy
Version: 10.1.x-dev » 1.0.x-dev
Component: Classy theme » Code

Discussed in #frontend. markconroy suggested that this should be moved to the contrib project. I am doing that now.