Needs work
Project:
Drupal core
Version:
main
Component:
Claro theme
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
31 Jan 2019 at 10:08 UTC
Updated:
11 Apr 2024 at 10:16 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
lauriiiComment #3
huzookaComment #4
huzookaLet me check how this can be done...
Comment #5
huzookaComment #6
huzookaIt seems that in core, the form elements with inline label are controlled by adding the
container-inlineclass. But the actual approach is not standardized and sometimes it causes invalid markup.Result of my research of
container-inlineusage:/node/1/edit
CKEditor image dialog
Maximum image resolution
Minimum image resolution
'Preview'
/search/user
etc
Add new filter option
Select an option in the list
end <div> tag is added by a separate form element
Add new field 'Tags'
Open 'Multiple field settings'
Explanation of Effect type column:
means that the HTML class is added directly to the form element's
#attributesarray (here I mean theform_elementtheme wrapper)means that the form element's content (label, input, prefix/suffix and description as well) is rendered inline because some of it's parent wrapper has the HTML class
container-inlineComment #7
huzookacontainer-inlineclass and if it has, we can replace it with aform-item--inlineclass (that would be the inline variation's modifier class).Indirect cases — I feel that some of them could be replaced by a combined usage of
form--inlinemodule (see #2417111: Replace container-inline with form--inline to display forms horizontally.) and our newform-item--inlinemodifier.The
form--inlineCSS module makes a set of form items (form__elements) inlined, and this is the right approach IMHO since its not so general like thecontainer-inlinemodule is.In the described case, the best solution would be to add some API for inline form items right in core, and reduce the usage of
container-inlineas much as possible...Comment #8
huzookaWe need the inline form item design extended with a description, a prefix/suffix and an error message.
Comment #9
ckrinaComment #10
ckrinaPostponing until we get the design done.
Comment #11
huzookaComment #12
ckrinaComment #13
ckrinaComment #14
boulaffasae commentedUpdated text inputs prefix
Comment #15
ckrinaComment #17
aleevasFixed failed tests
Comment #18
bnjmnmBefore additional patch-making, the IS should be updated so the scope is clear (and clearly not prefix/suffix related)
Comment #19
ckrinaUpdated the image and the focus on the Issue Summary. Ready to resume the work.
Comment #20
lauriiiWe need a test page for testing inline fields with descriptions since we don't have any use cases of that in core. We could either create a testing patch or add this to cd_tools.
Comment #21
ckrinaComment #22
bnjmnmHere's a test module that provides a form at inline-form-element-test with inline text, radio, checkbox and textarea fields.
Comment #23
bnjmnmForgot to include a select element in the previous patch. Use this one instead.
Comment #24
bnjmnmThis is a start but definitely needs more work- anybody is welcome to pick up from here.
InlineElementFormin the test module needs to be expanded to cover errors and probably prefix/suffix ( if prefix/suffix is suitable for inline form elements, we'd need designs for that)Screenshots attached of container-inline usage with the new styles.
Note that there is more markup than the old use of container-inline, but it also doesn't have the excessive side effects of the ruthless wildcard usage in core's container-inline styles
Comment #25
bnjmnmThis is a mountain of screenshots that will be given more context in a followup comment. Uploading them here to make the comment-making a little easier.
Comment #26
bnjmnmA screenshot is attached that includes inline form errors. Those are not currently covered in the design, so if they don't look right here then some design input will be needed to determine how they should be displayed.
This patch has some refactoring and additional styling to account for all the use cases in #6 (other than views, which is being handled in #3066006: Convert Views UI to new design system). There's a bit of edge-casing going on, but may still be preferable to the edge-case-riddled approach of setting
.container-inline * {display: inline}Comment #28
bnjmnmHad to account for ConfirmClassyCopiesTest
Comment #29
bnjmnmNote that the styling of inline image resolution fields such as the ones found at
admin/structure/types/manage/article/fields/node.article.field_imagewon't look ideal until #3082672: Form prefix/suffix redesign in Claro. There is SO much to review that there's no reason to changed the status to postponed waiting on that issue. Several iterations will likely take place before that's the final item before completion.Comment #30
bnjmnm*1 of 4 : patch and basic screenshots*
There's a large amount of information needed to properly review/implement/discuss this patch so this will be provided in four comments to make things easier to mentally organize (and type)
This patch builds on #28 addressing several things I spotted in review. The results can be seen in the screenshots.
The next comments will cover the use cases identified in #6, contrib modules that may be impacted by this change, and a suggested approach for error messages.
Comment #31
bnjmnm*2 of 4: use cases in #6*
Several of the items in #6 don't need to be in scope. Several are in themes, and the views items are being addressed in #3066006: Convert Views UI to new design system.
Action
https://www.drupal.org/files/issues/2020-07-17/Action-inline.png
Content Moderation
https://www.drupal.org/files/issues/2020-07-17/ContentModeration-inline.png
Editor (maximum dimensions)
https://www.drupal.org/files/issues/2020-07-17/EditorImageMaxDimensions-...
Editor (dialog radios)
https://www.drupal.org/files/issues/2020-07-17/ImageDialogAlign-inline.png
Field UI
https://www.drupal.org/files/issues/2020-07-17/FieldStorageConfigEditFor...
Image (shows both items listed)
https://www.drupal.org/files/issues/2020-07-17/ImageItem-minmaxResolutio...
Locale (the filter button is in container-inline ,but has no effect. This is the same in HEAD)
https://www.drupal.org/files/issues/2020-07-17/Translate-FilterButton-no...
Path
https://www.drupal.org/files/issues/2020-07-17/PathFilterForm-inline.png
Search (SearchPageForm)
https://www.drupal.org/files/issues/2020-07-17/Search-keywords-inline.png
Search (SearchPageListBuilder)
https://www.drupal.org/files/issues/2020-07-17/SearchPageListBuilder-inl...
Workspaces
https://www.drupal.org/files/issues/2020-07-17/WorkspaceSwitcher-default...
Comment
https://www.drupal.org/files/issues/2020-07-17/Comment-inline.png
Dblog (the filter button is in container-inline ,but has no effect. This is the same in HEAD)
https://www.drupal.org/files/issues/2020-07-17/Dblog-FilterButton-nothin...
Comment #32
bnjmnm3 of 4: Contributed modules that may be impacted
I used http://grep.xnddx.ru/ to find uses of
container-inlineandform--inline. If a module uses those classes in a way that is clearly covered by this patch, I did not include it in the list. I separated the remaining modules into two buckets.The modules in the first list should probably be notified that their use of container-inline or form--inline may have unexpected impact in Claro. Those classes (particularly container-inline) were too powerful in their reach which led to frequent unwanted side effects. The inconvenience presented here will reduce larger ones in the future.
Modules that either have D9 support or have enough evidence of usage/recent activity to suggest a D9 version is likely to be available
(I'm aware the site metrics for a module are not particularly accurate, this is just used to see which modules comparatively appear to have higher usage)
uses container-inline
uses form--inline
No Drupal 9 support +minimal usage and no recent activity
container-inline
form--inline
Comment #33
bnjmnm4 of 4: how to best proceed
Some concerns:
Inline form errors could stand to look a little better
I noticed errors weren't in the design so I shared some screnshots in Slack. @ckrina thought that they were largely fine, but the error message should be aligned with the corresponding input and not its label. I like this suggestion as well, but it would require some major refactoring. I think this would work best in a followup issue because
1) The alignment is no different in Seven, so this patch does not cause a regression even though it could be argued the alignment difference is more noticeable in Claro.
2) No new problems are introduced with the current scope, and this current scope is already quite complex due to the variety of ways .container-inline can be used.
The solution seems to include many bandages
The .container-inline class was a bit too powerful and had many unwanted side effects. Look at that +2 specificity determining the display of all child divs and labels
It was applied in a variety of ways that makes it incredibly difficult to remove/change the class in preprocess functions, particularly if contrib is taken into account. The approach in patch #30 does a bit of edge-casing when a broader solution like #3059593: Provide API for inline containers is more ideal. I think the approach in this patch is a step towards the feasibility of #3059593 landing. The changes here expose the use cases that would need addressing, and the CSS here can be repurposed.
Comment #34
bnjmnmDiscussed this with @lauriii, and these changes should address the majority of the concerns in the previous four comments.
The contrib concerns in #32 are addressed as the expected
.container-inlineand.form--inlineis now unchanged. There are already issues to address my primary concerns about those old issue, and it was pointed out that those concerns aren't quite as bad as I thought. This patch does add an alternative to the somewhat far-reaching.container-inlinestyling. A form can also add the class.form--inline-elements, which will inline-style every item in the form without the many side effects of the far-reaching.container-inlinestyle on an entire form. An example of this in use was added to the form in the test module.The concern about the bandage-ish approach in #33 is also resolved for the reasons stated above.
Screenshots
Test Form
This is labeled, but the first half are items individually wrapped in
.container-inlinethe second half is a group of items wrapped in a container with the.form--inline-elementsclass.https://www.drupal.org/files/issues/2020-07-28/inline-form-RTL-narrow.png
https://www.drupal.org/files/issues/2020-07-28/inline-form-RTL-wide.png
https://www.drupal.org/files/issues/2020-07-28/inline-form-narrow.png
https://www.drupal.org/files/issues/2020-07-28/inline-form-wide.png
IE11
https://www.drupal.org/files/issues/2020-07-28/form--inline-elements-add...
https://www.drupal.org/files/issues/2020-07-28/container-inline-plus-for...
https://www.drupal.org/files/issues/2020-07-28/container-inline-IE11-mob...
https://www.drupal.org/files/issues/2020-07-28/form--inline-elements-IE1...
https://www.drupal.org/files/issues/2020-07-28/container-inline-IE11-wid...
Other uses
Action
https://www.drupal.org/files/issues/2020-07-28/Actions.png
Comment
https://www.drupal.org/files/issues/2020-07-28/Comment_.png
Content Moderation
https://www.drupal.org/files/issues/2020-07-28/content-moderation.png
Dblog
https://www.drupal.org/files/issues/2020-07-28/Dblog-same_as_HEAD.png
Editor
https://www.drupal.org/files/issues/2020-07-28/EditorImageDialog.png
https://www.drupal.org/files/issues/2020-07-28/maximum-dimensions-editor...
Field UI
https://www.drupal.org/files/issues/2020-07-28/AddField.png
Image
https://www.drupal.org/files/issues/2020-07-28/ImageItem.png
Locale
https://www.drupal.org/files/issues/2020-07-28/Locale_same_as_HEAD.png
Node
https://www.drupal.org/files/issues/2020-07-28/NodePreview_same_as_HEAD.png
Path
https://www.drupal.org/files/issues/2020-07-28/PathFilterForm.png
Search
https://www.drupal.org/files/issues/2020-07-28/SearchPageForm.png
https://www.drupal.org/files/issues/2020-07-28/SearchPageListBuilder.png
Search Block + Workspaces Block
https://www.drupal.org/files/issues/2020-07-28/SearchBlock_WorkspacesBlo...
Comment #35
lauriiiComment #36
bnjmnmRerolled
Comment #37
lauriiiI think it would make sense to move some of these styles from these files to the specific components. While reviewing this, I went back and forth on many rules to check what are the styles that are being overridden.
Unnecessary
/* LTR */comment.I know these are just copy and paste from the pre-existing styles but should we at least convert these to using rem units?
Comment #38
katherinedAddressing #37:
1. I've reorganized in a way that made sense to me, so hopefully it's not just me. :)
2. Got it, and then moved it.
3. Got these, and also moved them.
Comment #39
lauriiiThank you for reorganizing the CSS rules @katherined!
Should we remove the test module from here since it's not being used anywhere?
Comment #40
katherinedAh, good idea. Test removed, and patch rerolled.
Comment #42
bnjmnmTest failure was an unrelated test infamous for intermittently failing
Comment #43
lauriiiShould we move this to Field UI specific file since this is not a form element type but specific form item in Field UI? I think #3082672: Form prefix/suffix redesign in Claro is adding more generic separator styles.
I think the separator would look better if it was centered in relation to the form elements, not label + form element.
.form--inline-elementslooks like it would be applying the BEM modifier pattern, but I don't think we have form block element?Is this utility class something that should be supported outside of Claro?
Comment #44
bnjmnm#43.1 Good call, moved these styles to field UI and opened an issue suggesting the same be done to all the instances outside of Claro #3169719: Move .form-inline .form-item-separator rules from inline-form css to field UI css
#43.2 That styling is already present in #3082672: Form prefix/suffix redesign in Claro, but it's not clear which will be added first so it'll go here as well and reroll as needed.
#43.3 Follow-up for aligning the description and error messages with the form element: #3169723: [PP-1] description and (inline)errors in inline forms should align with their element
#43.4
Shoot, that makes the class a little less self-explanatory, but it's true it should not follow the modifier pattern. Changed that here and will need to do that in #3083256: Create smaller variations for form elements as well.
#43.5
I'm sure that could be helpful throughout core. I created an issue for it: #3169734: [PP-1] Implement something similar to Claro's form-elements-inline class in all of core
Comment #45
bnjmnmIt may help to have a summary of the BEM issues being discussed in #43 and #44:
This issue and #3083256: Create smaller variations for form elements deal with creating form element variants. Currently, form elements receive variant styles by adding a class directly to the form element render array. The currently patches in this issue and #3083256: Create smaller variations for form elements offer a different way to provide variant styling to form elements: add a single wrapper class to the form, which will style every element within.
In the case of this issue, this would make is possible to present every element within a form as inline by adding the single
.form-elements-inlineclass to the form. Similarly , issue #3083256 proposes adding a wrapper class so all elements within a form can be styled as their small/extrasmall variants.At the moment I feel like the benefits of this approach outweigh the drawbacks of deviating from BEM. Were this approved for core, I'd still want to specifically document why the exception was made and why it should not be seen as an overall loosening of a standard that has proven beneficial.
Here are some of the specific reasons I support the approach, perhaps there are specific holes in the logic.
Prevents unwieldy form alters
Without the wrapper classes, providing variant styles to every element in a form means explicitly adding a class (and in the case of inline form elements, some element types require to to be added a #prefix/#suffix or #theme_wrapper). This results in some very busy form_alters to accomplish what a single wrapper class could, and I'm skeptical of it being possible to address this through any sort of helper function that recursively traverses the array to add these classes, due to the application of these classes differing depending on element type and other contexts that are less predictable.
Contrib modules aren't expected to do Claro-specific class additions.
Many contrib modules add elements to existing forms. Without the variant-facilitating wrapper class, contrib modules will need to add Claro-specific classes to every added form element. With the wrapper class, the added elements integrate with the rest of the form automatically. Contrib maintainers don't need to devote dev time to adding Claro classes, and there's less risk of poor sentiment towards Claro because contrib modules don't look right in it.
There is a greater need for form element variants in Claro, which increases the need for an easy way to apply them
Claro's form elements are very large, which benefits the user in many ways. There are contexts, however, where this large size is detrimental, such as when they appear in a dialog or views filters. There's already agreement that in contexts such as these, it's useful to use smaller variants within the entire form. Making this possible via the addition of a single class seems far preferable than the form_alter headaches mentioned above.
This provides an easy way to have context-dependent form element variants
For example, a form can easily use default styling in a page, and smaller variants inside a dialog.
Some elements are not easily alterable
In cases like views, where there are form elements that are not inside an actual form array, it's not always straightforward (or possible?) to add classes to specific elements. While it's true that theoretically all of these should be alterable and issues could be filed for each need, it's a plate of vegetables that are at risk of spoiling before they are fully eaten. A variant-facilitaing wrapper class makes this a non-concern.
Additional thoughts
Seeing a form element as part of a form vs being a discrete block is likely the way many of us conceptualize things already. While BEM effectively prevents unpredictable behavior, in the case of form elements, I don't feel like it would be particularly jarring for a form element to assume the variant state of its constituent elements vs retaining it's block-level styles. I think that core's BEM policy could define an exception specific to forms and their elements.
I also think that these wrapper classes should only exist if there are block-level versions of them as well. It should always be possible to style a variant on a per-element basis.
Comment #46
katherined+1 to the thorough and convincing explanation in #45.
Comment #47
tanubansal commentedTested #44 on 9.1
This can be moved to RTBC
Comment #48
lauriiiDiscussed with @alexpott. Ideally, this would part of Form API. However, making changes to Form API is difficult so we support the idea of having an intermediate solution prior to that. In particular, the argument about contrib extensibility sounds important.
We thought that the next steps could be:
Comment #49
katherinedFollow-ups are here: #3170928: Add form variants to the Form API and #3170933: Use Form API to implement form variants
Comment #50
bnjmnmThis takes care of the remaining item in #48
Comment #51
katherinedtiny nit: repeated "with" in comments with this opening line
I don't see anything else, so I think this is ready to RTBC otherwise.
Comment #52
bnjmnmThis addresses #52 and changed the wrapper class .form-elements-inline to .claro-form-elements-inline so the prefix makes it clear this is provided by Claro and not all of core.
Comment #53
bnjmnmComment #54
bnjmnmPrevious patch was missing a few compiled files
Comment #55
katherinedThe changes look right to me. Marking RTBC.
Comment #56
lauriiiWondering how the design system expects this to be rendered; some of the examples use colon and some are not using it. If we remove this, I don't think we use colon anywhere.
Instead of duplicating this in multiple files, let's add @see referencing container-inline.pcss.css.
Let's add @see reference to clearfix.module.css here.
Do we really need these? Based on quick visual test, it almost look like these are centered more accurately without these.
I guess this is needed for better consistency in the designs. However, I'n not certain if we should do that given that this could make text invisible on small screens:
It seems like there's some additional space on top of this margin which should be taken into account on this. Right now the space looks larger than on designs:

Comment #57
bnjmnm#56.1
Right, I made a judgement call here that ought to have been documented in the issue. The Figma designs state
HAS LABEL-COLON: textfield and radios
NO LABEL-COLON: textarea, select, machine name, checkboxes
I decided to remove the colon entirely (knowing it may lead to discussion) for the following reasons:
#56.2
Yep that's better
#56.3 Added the @see
#56.4 These definitely aren't needed. Were likely a part of an earlier iteration and missed as they only target .container-inline and tests may have only been done with the wrapper class.
#56.5 Found a solution that works pretty good.
#56.6 Looks like that was happening with .container-inline but not .claro-form-elements-inline. Setting display: flex on .form-item, as it already does with .claro-form-elements-inline, takes care of it.
Comment #58
katherinedRe #56.4, it looks to me like these are needed, as the elements with the container-inline class look misaligned without. Maybe a comment with these would help?

The rest looks good to me, and the colon explanation works for me, unless it warrants further discussion.
Comment #59
bnjmnmLooks like there was a style specific to the wrapper class that can also be used by container-inline and it fixes the issue repported in #58. This patch also adds a wrapper class equivalent to a container-inline style that was missing it.
Comment #60
katherinedThe issue in #58 looks resolved, thanks! And good catch on adding the wrapper class.
The below looks like it could use the same treatment (unless there is a reason not to?):
Pending the above, I think it's ready to go back to RTBC.
Comment #61
bnjmnm#60 isn't needed as those styles are specific to a use of .container-inline that isn't covered by the wrapper class. This is for displaying the elements of a form next to each other instead of stacked, such as the usage in admin/config/system/actions

This did lead to me discovering that this use of container-inline was broken by the fix for #56.6, which replaced the inline-block styling for .form-item with flex. This has been refactored to more specific targeting, so the margins should now be consistent regardless of the approach used, and container-inline can still be used to display elements next to each other.
Comment #62
katherinedThis looks like it works! The spacing now appears consistent between .container-inline and the wrapper class.
I have no other issues to report, so marking as RTBC.
Comment #63
ckrinaI can see how the different examples led to confusion about the colon: we considered it more a content decision rather than a forced element on any specific type of field.
We don't have any reason to force the colon on a visual design perspective, so I'd +1 @bnjmnm decision about deleting them completely.
Comment #64
lauriiiSeems like form elements and buttons are not positioned correctly inline if one of the elements have description.
Comment #65
bnjmnmGreat catch, this should address #64
Comment #66
lauriiiI don't think this is quite right either. The form elements are now aligned correctly but the button is now always misaligned.
Comment #67
bnjmnmThis seems to take care of it based on reviewing the usages in #6. Here are screenshots of the usages impacted by these changes.

Comment #68
katherinedI manually checked the affected forms, and all look good. I see nothing else in the code to comment on, so moving back to RTBC.
Comment #69
lauriiiIs the date time form element supposed to look like this with the
.claro-form-elements-inline?The form element looks like this with
.container-inline.Comment #71
bnjmnmThis needed a reroll.
Re #69 The datetime element should look the same with
.claro-form-elements-inlineand.container-inline, and for me it is looking the same. For that particular element, it would even look like that without either of those classes, as datetime-form.html.twig adds an entirely different class that results in the date and time being next to each otherPlus
.form-items-inline > .form-itemIf I get steps on how to reproduce the stacking in #69 I'll address whatever is causing it.
Comment #72
ckrinaI think this could use a reroll (or better, open a Merge Request) and update it. Some clues here: @lauri mentioned a test seems to be failing.
Comment #73
ckrinaComment #74
joegraduateI'm working on a re-roll (via a merge request).
Comment #76
joegraduateRe-rolled #67 as a MR. Here is the plain diff that can be used as a patch, if needed: https://git.drupalcode.org/project/drupal/-/merge_requests/559.diff
Tugboat live preview:
https://mr559-58yfpbqxizvkv518ouxtbz7fzteksjbh.tugboat.qa/
Comment #77
joegraduateComment #78
joegraduateComment #79
joegraduateLooking into this test failure:
Comment #80
joegraduateComment #82
volkswagenchickAdding tag for DrupalCon
Europe2021. ThanksComment #83
joegraduateComment #84
ckrinaThis needs a reroll.
Comment #86
kostyashupenkoRebase is done
Comment #87
feuerwagenComment #90
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. 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 #92
tonibarbera commentedRerolled the MR for Drupal 10.1.5 and attached interdiff.
Comment #93
_utsavsharma commentedFixed failures in #92.
Comment #94
finnsky commentedRE: #93
Thank you for work!
One point:
Really not sure. Why all css custom properties listed in few files?
Maybe add dependency to file which contains them?
Comment #95
gauravvvv commentedWe have
css/base/variables.cssalready available in global-styling. There is no need to import it in any particular file. I have removed the import. Attached interdiff and patch for same.Comment #96
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".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #97
omsingh89 commentedCould we have this patch https://www.drupal.org/files/issues/2023-10-25/3029675-93.patch for Drupal core 10.2.1 version please? Thanks in Advance.
Comment #98
akalam commentedRerolled #93 against core 11.x
Comment #99
akalam commentedThis one is for 10.2.5