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
| Comment | File | Size | Author |
|---|---|---|---|
| #45 | 2912824-45.patch | 2.91 KB | arantxio |
| #43 | Screen Shot 2023-04-13 at 7.53.50 AM.png | 58.8 KB | bnjmnm |
Issue fork drupal-2912824
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:
- 2912824-inappropriate-trailing-colons
changes, plain diff MR !3606
Comments
Comment #2
neograph734I 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:
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:
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:
Finally there is an issue with radio buttons no longer aligning with their labels in RTL languages as can be seen below:
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:
Or by changing the existing definition in stable/css/system/components/container-inline.module.css:
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?
Comment #3
neograph734I guess this status is most applicable?
Comment #4
joelpittetJust Active, the other status means this https://www.drupal.org/node/156119#patch-to-be-ported
Comment #5
ivan berezhnov commentedComment #8
texas-bronius commented@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?
Comment #9
texas-bronius commentedPartial 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.
Comment #10
joelpittetComment #12
bnjmnmI manually tested by making Bartik the admin theme and opened image dialog in CKEditor.
The selector
does not reach the radio label. There is no instance of
.container-inline.form-radiosIt 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🙂.
Comment #13
kostyashupenkoComment #14
kostyashupenkoComment #16
bandanasharma commentedI have reroll the patch and make changes as per above comment.
Comment #18
bandanasharma commentedReroll the patch again.
Comment #19
bandanasharma commentedComment #21
komalk commentedFixing test case review the patch.
Comment #22
neograph734I was about to RTBC this, but then in a code review I ran into the following:
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.
That theme uses slightly different margins:
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.Comment #23
neograph734Comment #29
smustgrave commentedWhat 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
Comment #30
pameeela commentedThe 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?
Comment #31
bnjmnmConfirmed 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
Comment #32
needs-review-queue-bot commentedThe 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.
Comment #34
pameeela commentedMade an updated MR with the changes from #2912824-22: Inappropriate trailing colons in Claro and Umami just applied to the current core themes.
Comment #35
smustgrave commentedWonder if this will require a simple test case to check if the colon is there or not. Or is that overkill?
Comment #36
smustgrave commentedPosted to #bugsmash and @mstrelan commented
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.
Comment #37
pameeela commentedOops! Fixed.
Comment #38
smustgrave commentedThanks!
Comment #39
bnjmnmChanges 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.
Comment #41
rpayanmPlease review.
Comment #42
smustgrave commentedThreads appear to be answered
Moving to NW per #39 for screenshots and issue summary update please.
Comment #43
bnjmnmI 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.
Comment #45
arantxioBecause the merge request is currently not mergeable I've created a new patch that applies to D10.1.x