Problem/Motivation

A follow-up from #2236789: Styling of inline radios broken: inappropriate trailing colons (breaks EditorImageDialog) for the bug in classy of having colons on radio buttons through classy.
This will be an issue for any using .container-inline CSS that originated from Classy (most easily verfied by it being in a themes /classy subdirectory).

Proposed resolution

Remove colons from radio button labels in .container-inline inline containers.

Remaining tasks

User interface changes

No more colons on radio button labels in inline containers and any additional style changes that are necessary for this change to look right within a form.

Steps to reproduce

Reproducing requires having a radios field inside an element with the .container-inline class. In Drupal 10, the only forms that have this out of the box are deprecated and CKEditor 4 specific, so it's probably easier to manually create a form with a radios element wrapped in .container-inline, or just manually add the .container-inline class with browser developer tools.

Despite it not appearing anywhere in core currently, the .container-inline wrapper does need to properly support any field type as contrib could be making use of container-inline form elements with radios.

API changes

Issue fork drupal-2912824

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joelpittet created an issue. See original summary.

neograph734’s picture

StatusFileSize
new3.17 KB
new1.9 KB

I know that classy and stable have been frozen, but they have a bug. Hence this issue to highlight and hopefully correct this. Thanks @joelpittet for the initial creation of this issue.

The problem is that some classes in the code no longer match the styles that are used in the CSS. The problem is in classy/css/components/container-inline.css:

.container-inline label:after,
.container-inline .label:after {
  content: ':';
}
.form-type-radios .container-inline label:after {
  content: '';
}

The problem is that .form-type-radios does not exist. It is either .form-type-radio (or the parent class .form-radios). This results in the trailing colons not getting removed from inline radio's, leading to a bad user experience:

Trailing colon bug

Because of the non-existing .form-type-radios, the following bit of CSS also no longer applies and as such is useless. Moreover this only worked for LTR languages. For RTL languages the indentaion was in the wrong direction. This has been resolved in seven per request of lauriii in #2236789-91: Styling of inline radios broken: inappropriate trailing colons (breaks EditorImageDialog). Since it is not used I believe this part can be removed from classy:

.form-type-radios .container-inline .form-type-radio {
  margin: 0 1em;
}

Finally there is an issue with radio buttons no longer aligning with their labels in RTL languages as can be seen below:

Radio button alignment bug

In order to overcome this, the container-inline div and label should be inline-blocks rather than inline elements. This too has been resolved in #2236789: Styling of inline radios broken: inappropriate trailing colons (breaks EditorImageDialog) (and I can imagine this beging a potential disruptive change) . But it can be resolved by adding this to classy:

.container-inline div,
.container-inline label {
  display: inline-block;
}

Or by changing the existing definition in stable/css/system/components/container-inline.module.css:

.container-inline div,
.container-inline label {
-  display: inline;
+  display: inline-block;
}

I'd be happy to provide patches for the indicated bugs, but would like some feedback on the desired approach. The first bug would be the least disruptive change and would restore desired (and probably previous) behavior.
The second piece of code does not do anything and will hopefully be in seven when #2236789: Styling of inline radios broken: inappropriate trailing colons (breaks EditorImageDialog) lands. It can be removed, but it can be left doing nothing as well.
The 3rd piece of code is a requirement for correct handling of RTL radio's and labels but has the potential to break existing themes. What is more important, a good UI, or the risk of affecting one or more themes?

neograph734’s picture

Status: Active » Patch (to be ported)

I guess this status is most applicable?

joelpittet’s picture

Status: Patch (to be ported) » Active

Just Active, the other status means this https://www.drupal.org/node/156119#patch-to-be-ported

ivan berezhnov’s picture

Issue tags: +CSKyiv18

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

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.

texas-bronius’s picture

@neograph734 - excellent analysis :) I am running into this as well (Drupal 8 system classy theme forces colons on container-inline radio labels where they do not belong) and would like to help work toward a fix. Is it best to -remove- the cited container-inline :after lines or override with radio-specificity to undo it?

texas-bronius’s picture

Version: 8.6.x-dev » 8.7.x-dev
StatusFileSize
new851 bytes

Partial patch per #2, addresses inappropriately added colons on container-inline radios and checkboxes and provides the required whitespace as Classy had originally intended, before the radios and checkboxes wrappers selectors had changed in 8.5.x core. I didn't look at anything else like ltr/rtl that Neograph734 mentioned in #2.

joelpittet’s picture

Status: Active » Needs review

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

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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.

bnjmnm’s picture

Status: Needs review » Needs work

I manually tested by making Bartik the admin theme and opened image dialog in CKEditor.
The selector

+++ b/core/themes/classy/css/components/container-inline.css
@@ -7,12 +7,12 @@
+.container-inline.form-radios label:after,

does not reach the radio label. There is no instance of .container-inline.form-radios
It will work with this selector .container-inline.form-radio ~ label:after, but there may be a more elegant way to accomplish this.

I'll keep an eye on this issue to review and RTBC as we're in the process of removing all core theme dependencies on Classy in #3050389: [META] Remove dependency to Classy from core themes. This includes copying many Classy assets to those themes, and I'd like to avoid copying ones with known bugs🙂.

kostyashupenko’s picture

Status: Needs work » Needs review
StatusFileSize
new2.96 KB
kostyashupenko’s picture

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

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.

bandanasharma’s picture

StatusFileSize
new2.85 KB

I have reroll the patch and make changes as per above comment.

Status: Needs review » Needs work

The last submitted patch, 16: theme-classy-2912824-16.patch, failed testing. View results

bandanasharma’s picture

StatusFileSize
new2.85 KB

Reroll the patch again.

bandanasharma’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 18: theme-classy-2912824-16.patch, failed testing. View results

komalk’s picture

Status: Needs work » Needs review
StatusFileSize
new1.78 KB
new5.11 KB

Fixing test case review the patch.

neograph734’s picture

Title: Inappropriate trailing colons in classy » Inappropriate trailing colons in Classy and Bartik and Umami
StatusFileSize
new14.55 KB
new8 KB

I was about to RTBC this, but then in a code review I ran into the following:

.form-type-radios .container-inline label:after,
.form-type-checkboxes .container-inline label:after {
  content: "";
}
.form-type-radios .container-inline .form-type-radio,
.form-type-checkboxes .container-inline .form-type-checkbox {
  margin: 0 1em;
}

The margin also suffers form the exact same mixup of classes. Only making the colons work and leaving the other wrong CSS in place feels wrong. So we should either fix the margin too, or remove it entirely.

But when I was testing this patch with different themes I noticed that the Seven theme gives a much better user experience than applying a margin on both sides.

seven

That theme uses slightly different margins:

.container-inline .form-radios .form-type-radio,
.container-inline .form-checkboxes .form-type-checkbox {
  margin-right: 1em;
}
[dir="rtl"] .container-inline .form-radios .form-type-radio,
[dir="rtl"] .container-inline .form-checkboxes .form-type-checkbox {
  margin-right: 0;
  margin-left: 1em;
}

I have added that to the patch. I know it goes somewhat outside the scope of the title, but since the margin code is already there and suffers from the same mixup, I believe this has always been the intended behavior. If not desired, we should at least delete the margin: 0 1em, as currently these margins are not doing anything.

neograph734’s picture

Issue tags: +Bartik, +Umami

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.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update

What are the steps to replicate this?

Also seven + bartik have been removed in D10 so would need to determine if this is a problem in claro + olivero

pameeela’s picture

The same CSS is included in Claro, but I'm not able to trigger the issue described without steps to reproduce. I've never seen this issue before in the wild either.

Leaning toward closing without further info?

bnjmnm’s picture

Component: Classy theme » CSS
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review
Issue tags: -Needs issue summary update

Confirmed this is still happening in Claro/Umami (did not test Olivero). I added steps to reproduce in the IS. The only core instance of this seems to be in deprecated CKEditor 4 related forms, but this issue should remain open since .container-inline should fully support all core form elements, even if they don't happen to appear in an inline form.

This requires some extra steps to reproduce so I'm not sure what kind of momentum this issue will have going forward, but the problem still exists

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new85 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

pameeela’s picture

Title: Inappropriate trailing colons in Classy and Bartik and Umami » Inappropriate trailing colons in Claro and Umami
Status: Needs work » Needs review

Made an updated MR with the changes from #2912824-22: Inappropriate trailing colons in Claro and Umami just applied to the current core themes.

smustgrave’s picture

Wonder if this will require a simple test case to check if the colon is there or not. Or is that overkill?

smustgrave’s picture

Status: Needs review » Needs work

Posted to #bugsmash and @mstrelan commented

The colon is never really there. I'm not sure if we can even check pseudo-elements? Either way I think PHP should trust that CSS is doing CSS things, it would be more appropriate to check that PHP / twig is outputting the appropriate markup so CSS can style it accordingly. That may already exist?

So since this is pure css don't think we need tests then.

But there was a CI failure in the MR.

Hiding the files as the work is being done in the MR now.

pameeela’s picture

Status: Needs work » Needs review

Oops! Fixed.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

bnjmnm’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs screenshots, +Needs issue summary update

Changes requested in MR.

Also, lets celebrate that this is the rare occasion where I'm tagging "needs screenshots" instead of wearily pointing out there are too many of them. There should be shots for Claro and Umami with checkboxes and radios.

rpayanm made their first commit to this issue’s fork.

rpayanm’s picture

Status: Needs work » Needs review

Please review.

smustgrave’s picture

Status: Needs review » Needs work

Threads appear to be answered

Moving to NW per #39 for screenshots and issue summary update please.

bnjmnm’s picture

StatusFileSize
new58.8 KB

I mentioned earlier that the Claro solution was using selectors that don't exist in Claro. It looks like the Claro changes were removed entirely, when the solution should be changing them to the correct selector.

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

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

arantxio’s picture

StatusFileSize
new2.91 KB

Because the merge request is currently not mergeable I've created a new patch that applies to D10.1.x

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.