Problem/Motivation

In form-text.css, .form-element width is set to 100% at widths up to 600px. This pushes prefixes and suffixes to a new line in a way that doesn't look good. (Found using Umami profile on Chrome at admin/config/media/image-toolkit)

Testing instructions

  • Enable Claro as the administration theme if it is not.
  • Visit /admin/config/system/site-information and verify the Default front page field.
  • Test it working with the focus design (using the keyboard to navigate to this field, for example).
  • Visit /admin/config/media/image-toolkit and verify the JPEG quality field.
  • Navigate to /admin/structure/types/manage/page/fields and start adding a field. Before saving it, edit the machine name.The preffix "field" should look like a preffix.
  • Enter a wrong machine name (like add and space in the middle) and verify the error looks as in the designs.
  • Test the focus working fine with the error.
  • Add several combinations of Number fields with Prefix and suffix, and multiple fields too.
  • Visit /admin/structure/views/view/comment and click on edit Path under "Page settings". The field path on the dialog should look OK (no prefix).
  • Visit /user/1/edit and edit the Password field. The confirm password field shouldn't be visible until a password is entered, and the input and strength indicator shouldn't be too wide. (Per comment #66).

Outside of scope:

Proposed resolution

Implement a new design to solve this:

This image is just a reference. Please use this Figma link to check spacing and other definitions.

Remaining tasks

  • Create a new design
  • Accessibility review
  • Create a new patch

User interface changes

A new design for prefix will be available.

Release notes snippet

Known Issues


1- Visit /admin/structure/views/view/comment and click on edit Path under "Page settings". The field path on the dialog should look OK (no prefix).
View path prefix
This is an issue with Views actually, since it's adding some HTML to the prefix without checking if there is a value, see: https://git.drupalcode.org/project/drupal/-/blob/9.4.x/core/modules/view...
which ends up with an empty prefix with just a "&lrm;" entity on it. (Although the problem seems to be that Url::fromRoute('<none>', [], ['absolute' => TRUE])->toString() it's returning an empty string). In any case, should this be addressed in a separate ticket for Views and not for Claro.
CommentFileSizeAuthor
#169 interdiff-168_169.txt1.02 KBgauravvvv
#169 3082672-169.patch77.24 KBgauravvvv
#168 interdiff-167-168.txt1.3 KBsrishtiiee
#168 3082672-168-101x.patch72.57 KBsrishtiiee
#167 Screenshot 2023-04-24 at 6.35.53 PM.png26.07 KBsrishtiiee
#167 interdiff-165-167.txt464 bytessrishtiiee
#167 3082672-167-101x.patch72.83 KBsrishtiiee
#166 Screen Shot 2023-04-24 at 12.39.11.png10.24 KBlauriii
#165 3082672-166-101x.patch72.38 KBlauriii
#161 rtl.png45.2 KBmherchel
#161 views-path.png425.7 KBmherchel
#154 Screen Shot 2022-05-04 at 4.05.38 PM.png767.54 KBdeviantintegral
#149 3082672-149.gif1.01 MBjavi-er
#148 3082672-14470427.gif91.15 KBjavi-er
#142 Screen Shot 2022-03-24 at 2.56.11 PM.png135.93 KBdeviantintegral
#142 Screen Shot 2022-03-24 at 2.41.12 PM.png216.32 KBdeviantintegral
#135 path-claro.png58.47 KBckrina
#135 path-seven.png48.25 KBckrina
#135 screenshots.png100.3 KBckrina
#130 14420288-130--test-ie-expanded.png941.43 KBjavi-er
#130 14420288-130--test-ie.png889.22 KBjavi-er
#125 test-modern-browsers-behaviors.png52.18 KBckrina
#125 test-modern-browsers.png72.31 KBckrina
#125 test-normal-field-label.png15.52 KBckrina
#125 test-IE11-no-js.png94.92 KBckrina
#120 prefix-firefox.png14.72 KBckrina
#120 prefix.mp42.75 MBckrina
#113 interdiff_107-113.txt15.06 KBbnjmnm
#113 3082672-113.patch65.21 KBbnjmnm
#107 3082672-107.patch48 KBlauriii
#103 interdiff_99-103.txt7.47 KBbnjmnm
#103 3082672-103.patch48.85 KBbnjmnm
#99 3082672-99-REROLL.patch49.28 KBbnjmnm
#97 3082672-97.patch52.23 KBbnjmnm
#97 interdiff_94-97.txt4.95 KBbnjmnm
#96 password-test-HEAD.jpg23.95 KBkatherined
#96 password-test-patch.jpg41.53 KBkatherined
#94 3082672--94.patch50.47 KBbnjmnm
#94 interdiff__86-94.txt12.96 KBbnjmnm
#94 Presuf-Screenshots.zip11.27 MBbnjmnm
#90 Screenshot 2020-08-28 at 14.16.51.png143.39 KBlauriii
#86 3082672-86.patch47.34 KBbnjmnm
#86 interdiff_81-86.txt1.13 KBbnjmnm
#86 Screen Shot 2020-08-21 at 12.44.31 PM.png120.91 KBbnjmnm
#85 prefix_suffix_specification.png318.2 KBsaschaeggi
#84 prefix_test.png19.2 KBsaschaeggi
#83 Captura de Pantalla 2020-08-21 a les 15.15.21.png4.11 KBckrina
#81 interdiff_74-81.txt4.1 KBbnjmnm
#81 3082672-81.patch47.57 KBbnjmnm
#81 new-presuf-colors.png110.24 KBbnjmnm
#80 Screenshot 2020-08-20 at 15.30.27.png15.63 KBlauriii
#80 Screenshot 2020-08-20 at 15.25.39.png21.97 KBlauriii
#74 3082672-74.patch47.44 KBbnjmnm
#74 interdiff_69-74.txt3.34 KBbnjmnm
#69 3082672-69.patch47.57 KBbnjmnm
#69 interdiff_67-69.txt1.82 KBbnjmnm
#67 interdiff_65-67.txt7.26 KBbnjmnm
#67 3082672-67.patch47.39 KBbnjmnm
#66 stacked--focus_ie.jpg15.85 KBkatherined
#66 stacked--chrome.jpg34.82 KBkatherined
#65 3082672-65.patch45.25 KBbnjmnm
#65 interdiff_62-65.txt1.09 KBbnjmnm
#63 claro-add-field.png39.82 KBbnjmnm
#63 seven-add-field.png77.55 KBbnjmnm
#62 3082672--62.patch44.99 KBbnjmnm
#62 interdiff__59-62.txt21.55 KBbnjmnm
#59 interdiff_57-59.txt2.85 KBbnjmnm
#59 3082672-59.patch34.17 KBbnjmnm
#59 new-presuf1.png19.86 KBbnjmnm
#59 new-presuf2.png13.17 KBbnjmnm
#59 interdiff_57-59.txt2.85 KBbnjmnm
#59 3082672-59.patch34.17 KBbnjmnm
#58 presuf-img-resolution.png99.56 KBbnjmnm
#58 presuf-img-resolution-mobile.png36.95 KBbnjmnm
#57 interdiff_55-57.txt42.01 KBbnjmnm
#57 3082672-57.patch33.47 KBbnjmnm
#57 affix-screenshots.zip17.1 MBbnjmnm
#55 presuf5.png32.41 KBbnjmnm
#55 presuf4.png72.05 KBbnjmnm
#55 presuf3.png64.41 KBbnjmnm
#55 presuf2.png31.97 KBbnjmnm
#55 presuf1.png79.32 KBbnjmnm
#55 3082672-55.patch14.26 KBbnjmnm
#55 interdiff_49-55.txt12.04 KBbnjmnm
#53 prefix-sufix.png129.52 KBckrina
#53 previous.png63.85 KBckrina
#50 edit-machine-name.png22.33 KBbnjmnm
#49 claro-form_prefix_suffix-3082672-49.patch9.18 KBhuzooka
#48 Prefix-suffix--windows-ubuntu.zip11.97 MBhuzooka
#48 Prefix-suffix--osx-mobile.zip18.66 MBhuzooka
#48 interdiff-3082672-45-48.txt9.16 KBhuzooka
#48 claro-form_prefix_suffix-3082672-48.patch10.59 KBhuzooka
#46 Prefix-suffix--osx.zip9.8 MBhuzooka
#45 Prefix-suffix--mobile.zip9.09 MBhuzooka
#45 interdiff-3082672-44-45.txt7.21 KBhuzooka
#45 claro-form_prefix_suffix-3082672-45.patch9.06 KBhuzooka
#44 claro-form_prefix_suffix-3082672-44.patch7.51 KBhuzooka
#39 Screen Shot 2019-11-08 at 17.08.13.png56.33 KBlauriii
#39 Screen Shot 2019-11-08 at 17.08.00.png19.06 KBlauriii
#38 Claro-prefix-suffix-screenshots.zip750.59 KBhuzooka
#38 claro-form_prefix_suffix-3082672-38.patch7.57 KBhuzooka
#38 interdiff-3082672-33-38.txt7.88 KBhuzooka
#36 Screenshot 2019-10-31 at 15.59.13.png54.1 KBjoycelam
#36 Screenshot 2019-10-31 at 16.26.11.png53.04 KBjoycelam
#33 interdiff_22-33.txt3.29 KBcgoffin
#33 claro-form_item_prefix_suffix-3082672-33.patch3.8 KBcgoffin
#23 claro-form_item_prefix_suffix-3082672-22.patch4.42 KBhuzooka
#21 claro_form-element-type--number_fix_below_600px.PNG8.98 KBpzajacz
#21 claro.form_type_number_width_fix_below_600px-3082672-21.patch2.28 KBpzajacz
#17 Screenshot 2019-10-07 at 11.47.30.png47.07 KBhuzooka
#13 Screenshot 2019-10-06 13.28.51.png44.41 KBfhaeberle
#11 claro.form_type_number_width_fix_below_600px-3082672-11.patch1 KBpzajacz
#10 ff_ie_320px_form-with-suffix.PNG12.75 KBpzajacz
#7 claro.form_type_number_width_fix_below_600px-3082672-4.patch992 bytespzajacz
#4 claro.smaller_variations_for_inputs_and_selects-3083256-4.patch2.01 KBpzajacz
#2 claro_form-element-type--number_fix_below_600px.PNG8.16 KBpzajacz
#2 claro.form_type_number_width_fix_below_600px-3082672-1.patch414 bytespzajacz
suffix-newline.png38.49 KBbnjmnm

Issue fork drupal-3082672

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

bnjmnm created an issue. See original summary.

pzajacz’s picture

I used width: auto override on 600px and below because the 100% width pushes the suffix to a new line.
(Claro 8.x-1.x dev with Drupal 8.7.7)

lauriii’s picture

Status: Needs review » Needs work

The #field_suffix and #field_prefix are not specific to '#type' => 'number'. We should try to find solution that works with all field types without having to remove this usability enhancement.

pzajacz’s picture

I added a new class to wrapper form-item if it contains prefix or suffix element.
(UPDATE: wrong patch)

pzajacz’s picture

Status: Needs work » Needs review
lauriii’s picture

Did you post the right patch? I don't see any new classes being added in #4 🤔

pzajacz’s picture

StatusFileSize
new992 bytes

Sorry @lauriii, I uploaded the wrong patch, this is the good one:

lauriii’s picture

Status: Needs review » Needs work
Issue tags: +Usability

This fixes the problem on Chrome, but it seems like width: auto isn't enough to fix this in Firefox.

+++ b/templates/form-element.html.twig
@@ -24,6 +24,8 @@
+    prefix is not empty and disabled != 'disabled' ? 'form-item--prefixed',
+    suffix is not empty and disabled != 'disabled' ? 'form-item--suffixed'

Any thoughts on renaming these to form-item--with-prefix and form-item--with-suffix?

pzajacz’s picture

Ok, it's no problem, I rename the classes and try to fix the FF bug!

pzajacz’s picture

StatusFileSize
new12.75 KB

I need to add max-width:75% (or any other value) to the suffixed/prefixed input field on 600px and below because the field's width isn't working exactly as on Chrome. The field's default width is much wider on FF and IE. When I tested it on FF and IE, the width: auto is working, but the suffix is pushed to a new line on 320px screen, so the max-width: 75% is fixed this bug. Any other suggestion?

pzajacz’s picture

pzajacz’s picture

Status: Needs work » Needs review
fhaeberle’s picture

StatusFileSize
new44.41 KB

This looks like the current patch comes with the result that suffixed inputs works well but we only get 75% of the width for prefixed inputs like in

/admin/config/system/site-information

prefixed solution

Ideally, the prefix, suffix and input sharing one parent container where we could define a variable (but fixed min-) width for the input and let the prefix and suffix flow but that would also cause other problems. The main problem here is that we can't assume the width of prefix or suffix because they can be any length. Imho, it can be leaved as is (because of edge case) but if we want to improve it we need to have in mind that on other places, it could be worse with this change.

fhaeberle’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
Status: Needs review » Reviewed & tested by the community

Setting it to RTBC because the patch works and fixes the problem, but the concerns are described in #13

pzajacz’s picture

Another solution is when a JS calculate the width of the prefix/suffix, and it updates the input field's width (subtract from it). I know, it's not the perfect solution, but more accurate than playing with the max-width value. Should I try, maybe? (In this case, the JS is running after the DOM is rendered, so in some cases, it causes a little jump when the prefix/suffix is longer than 25% when we will use the 75% input field's default max-width.)

huzooka’s picture

Status: Reviewed & tested by the community » Needs work

Let's try what happens if we add a wrapper for the input and its prefix and suffix (when at least #prefix or #suffix is set), and use flex for styling them.

|prefix                         |input          |suffix                        |
================================================================================
|flex: 0 1 20%;                 |flex: 1 0 60%; |flex: 0 1 20%;                |
|max-width: calc(20% - 0.5rem); |               |max-width: calc(20% - 0.5rem);| 
|margin-right: 0.5rem; /* LTR */|               |margin-left: 0.5rem; /* LTR */|
huzooka’s picture

StatusFileSize
new47.07 KB

Screenshot for #16:

Screenshot about an input with prefix and suffix

pzajacz’s picture

Assigned: Unassigned » pzajacz

@huzooka Very good idea, I'll give it a try!

fhaeberle’s picture

Note: /admin/config/user-interface/shortcut/manage/default
This is a place where the break into a new line makes sense for suffix.

fhaeberle’s picture

Issue tags: +Novice, +DrupalCon Amsterdam 2019
pzajacz’s picture

Status: Needs work » Needs review
StatusFileSize
new2.28 KB
new8.98 KB

I tried @huzooka's idea, and it's working.

Prefixed-suffixed input screenshot

huzooka’s picture

Project: Claro » Drupal core
Version: 8.x-2.x-dev » 8.9.x-dev
Component: Code » Claro theme
huzooka’s picture

Status: Needs review » Needs work
StatusFileSize
new4.42 KB

Rebased what we had in #21.

I apologize, I just realized that this issue is assigned to @pzajacz.

pzajacz’s picture

Assigned: pzajacz » Unassigned

@huzooka I removed my assign! ;)
I think this task needs review and testing, or you know anything is missing from the patch?

fhaeberle’s picture

Status: Needs work » Needs review

Setting to needs review because of the rebased patch.

lauriii’s picture

Status: Needs review » Needs work
  1. +++ b/core/themes/claro/css/src/components/form.pcss.css
    @@ -114,6 +114,42 @@ tr .form-item,
    +  .form-item .form-item__wrapper {
    

    This could be simplified to just .form-item__wrapper.

  2. +++ b/core/themes/claro/css/src/components/form.pcss.css
    @@ -114,6 +114,42 @@ tr .form-item,
    +  .form-item--with-prefix .form-item__wrapper .form-element,
    

    This could be simplified to:

    .form-item--with-prefix .form-element,
    .form-item--with-suffix .form-element
    
  3. +++ b/core/themes/claro/css/src/components/form.pcss.css
    @@ -114,6 +114,42 @@ tr .form-item,
    +  .form-item--with-prefix .form-item__wrapper .form-item__prefix,
    +  .form-item--with-suffix .form-item__wrapper .form-item__suffix {
    

    This could be simplified to:

    .form-item__prefix,
    .form-item__suffix 
    
  4. +++ b/core/themes/claro/css/src/components/form.pcss.css
    @@ -114,6 +114,42 @@ tr .form-item,
    +  .form-item--with-prefix .form-item__wrapper .form-item__prefix {
    ...
    +  [dir="rtl"] .form-item--with-prefix .form-item__wrapper .form-item__prefix {
    

    These could be simplified to .form-item__prefix and [dir="rtl"] .form-item__prefix.

  5. +++ b/core/themes/claro/css/src/components/form.pcss.css
    @@ -114,6 +114,42 @@ tr .form-item,
    +  .form-item--with-suffix .form-item__wrapper .form-item__suffix {
    ...
    +  [dir="rtl"] .form-item--with-suffix .form-item__wrapper .form-item__suffix {
    

    These could be simplified to .form-item__suffix and [dir="rtl"] .form-item__suffix.

  6. +++ b/core/themes/claro/templates/form-element.html.twig
    @@ -36,6 +38,9 @@
    +  {% if prefix or suffix is not empty %}
    +    <div class="form-item__wrapper">
    +  {% endif %}
    
    @@ -48,6 +53,9 @@
    +  {% if prefix or suffix is not empty %}
    +    </div>
    +  {% endif %}
    

    I'm just wondering if it would make sense to simplify this component by always rendering this wrapper. 🤔 Any thoughts?

huzooka’s picture

+++ b/core/themes/claro/css/src/components/form.pcss.css
@@ -114,6 +114,42 @@ tr .form-item,
+  .form-item--with-prefix .form-item__wrapper .form-element,
+  .form-item--with-suffix .form-item__wrapper .form-element {
+    flex: 0 1 60%;
+  }

This limits the input with in 60%. I think that what we need here is flex: 1 0 60%;.

mradcliffe’s picture

Issue tags: -Novice, -DrupalCon Amsterdam 2019 +Amsterdam2019, +Needs issue summary update

Fixing the tag to be Amsterdam2019. I'm removing the novice at the moment as well, but will probably add it back on Wednesday.

fhaeberle’s picture

Issue tags: -Amsterdam2019 +DrupalCon Amsterdam 2019

Fixing the tags is a little confusing because we are working with this tag to identify issues which fit in the contribution during DrupalCon. Other projects use different tags but we decided to use this one. Would be nice if we keep the current tag, thanks.

Thanks a lot for your effort and time investment.

mradcliffe’s picture

Issue tags: +Novice

Sorry, for removing many of the tags, @fhaeberle. Usually core issues will follow the pattern [CITY]YYYY. Having a consistent tag for core issues helps contributors searching for novice issues. I'll leave this one though.

Edit: it also helps contribution event organizers and DA staff aggregate statistics for the event.

cgoffin’s picture

Working on it at DrupalCon Amsterdam 2019.

rachel_norfolk’s picture

Issue tags: -DrupalCon Amsterdam 2019 +Amsterdam2019

retagging

cgoffin’s picture

I adjusted the patch with the mentioned comments. I will also add the interdiff.

cgoffin’s picture

Status: Needs work » Needs review
joycelam’s picture

Hi, I'll be testing/reviewing this patch.

joycelam’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new53.04 KB
new54.1 KB

Thanks for the patch and thoughts.

So the input suffix on admin/config/media/image-toolkit and admin/config/user-interface/shortcut/manage/default looks great in Chrome/Safari/Firefox.

For the admin/config/system/site-information, however, the front-page input gets before the prefix. As described in #13 if I understand correctly.

Also, the input exceeds the screen in Firefox:

huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new7.88 KB
new7.57 KB
new750.59 KB

This patch:

  • Makes prefix, item and suffix sizes more flexible
  • Makes machine name suffix rendered in a new line

Handcrafted screenshots attached.

lauriii’s picture

Any thoughts on #26.6?

Visually this looks good:

huzooka’s picture

Status: Needs review » Needs work
huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

Assigned: huzooka » Unassigned
huzooka’s picture

Assigned: Unassigned » huzooka
huzooka’s picture

StatusFileSize
new7.51 KB

Still not addressing #26.6, this is only a rebase (without #3094696-3: Follow-up to #3084843: Re-generate production CSS files).

huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new9.06 KB
new7.21 KB
new9.09 MB

The attached patch addresses #26.6.

Mobile screenshots attached, others in progress.

huzooka’s picture

StatusFileSize
new9.8 MB

OSX screenshots attached.

Remaining:
IE11, MS Edge, Chrome on Windows and Ubuntu, Firefox on Windows and on Ubuntu.

huzooka’s picture

Assigned: Unassigned » huzooka
Status: Needs review » Needs work
huzooka’s picture

Assigned: huzooka » Unassigned
Status: Needs work » Needs review
StatusFileSize
new10.59 KB
new9.16 KB
new18.66 MB
new11.97 MB
huzooka’s picture

StatusFileSize
new9.18 KB

Re-rolled #48.

bnjmnm’s picture

Title: Form input suffix is pushed to newline at widths of 600px and below » Form input prefix/suffix pushed to newline at widths of 600px and below
Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new22.33 KB

Updated issue summary to reflect prefix and suffix being impacted.

In manual testing, I found that when adding a field and clicking "edit" to change the automatically generated machine name, the problem is still present. I'm guessing this is due to dynamically adding the prefix, so the .form-item__wrapper--with-prefix class is not added.

Everything else reviewed looks very good so I'm inclined to RTBC one the above is addressed or deemed out of scope with a followup.

ckrina’s picture

Issue tags: +Needs design

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.

ckrina’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update, -Needs design
Related issues: +#3029675: Add support for the inline variation of form elements
StatusFileSize
new63.85 KB
new129.52 KB

Here are the new designs for the prefix/suffix with a solution for the mobile/small spaces. I just updated the issue summary too.

bnjmnm’s picture

Assigned: Unassigned » bnjmnm

Excited to see these designs! Assigning to myself and I'll get to work on implementing them.

bnjmnm’s picture

Title: Form input prefix/suffix pushed to newline at widths of 600px and below » Form prefix/suffix redesign
Assigned: bnjmnm » Unassigned
Issue summary: View changes
Issue tags: -Novice
StatusFileSize
new12.04 KB
new14.26 KB
new79.32 KB
new31.97 KB
new64.41 KB
new72.05 KB
new32.41 KB

Here's round 1, which is resembling the new design but definitely needs work in these areas:

  • Styling that can handle very long prefixes/suffixes
  • Test in multiple browsers, especially IE since it is flex-picky

Contributors that would like to tackle this would benefit from using the clarodist tools module that provides several pages worth of different prefix/suffix scenarios. The two modules needed are https://github.com/lauriii/cd_tools and https://github.com/lauriii/cd_core. Enable the "Prefix Suffix" module and it will provide test pages at /contact/presuf_number, /contact/presuf_formatted, and /contact/presuf_text. You can modify the contents of presuf_number.module to use larger prefixes and suffixes.

bnjmnm’s picture

Status: Needs work » Postponed

Postponing on #3092296: Improve email address field description at /user/register. This will be implemented differently if it's inside a max-width'd container, and I think it may be a better solution overall.

bnjmnm’s picture

Status: Postponed » Needs review
StatusFileSize
new17.1 MB
new33.47 KB
new42.01 KB

We are now far enough along with #3092296: Improve email address field description at /user/register to know it won't impact the solution being implemented here.

Some JavaScript was necessary to elegantly support very long prefixes and suffixes in a way that didn't cause stacking when it wasn't actually needed. Very little styling is based on media queris, instead basing the behavior on the width of the affixes.

The solution still looks pretty good without javascript - definitely not as nice but far less diminished than many other nojs experiences in core.

Many screenshots attached.

bnjmnm’s picture

Status: Needs review » Needs work
StatusFileSize
new36.95 KB
new99.56 KB

Upon looking at an image field form such as admin/structure/types/manage/article/fields/node.article.field_image, it looks like there's a use case that still needs to be addressed.

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new34.17 KB
new2.85 KB
new13.17 KB
new19.86 KB
new34.17 KB
new2.85 KB

The edge case spotted in #58 is addressed here.

Note that the stacking is not ideal here, but this is a pre-existing problem not in the scope of this prefix/suffix issue. This will be addressed in #3029675: Add support for the inline variation of form elements

Status: Needs review » Needs work

The last submitted patch, 59: 3082672-59.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review

Back to NR, was switched to NW due to an unrelated test failure (as evidenced by the fact that I accidentally uploaded the patch twice, and the other upload didnt fail)

bnjmnm’s picture

StatusFileSize
new21.55 KB
new44.99 KB

Talked with @lauriii about the image resolution styling from #59. It was pointed out that the "x" and "pixels" don't actually function as prefixes/suffixes despite appearing before/after the fields. @lauriii also felt that adjusting the render array to generate these outside of a prefix/suffix was acceptable scope for this issue.

This patch also adds JavaScript behavior to help with machine name suffix styling. This required extra attention as machine name functions can be empty -- but when that's the case the suffix padding results in an extraneous gray box to the right of the input. It was apparent the CSS solution would not work when visiting an existing text format config form such as admin/config/content/formats/manage/basic_html as the selectors function differently.

bnjmnm’s picture

StatusFileSize
new77.55 KB
new39.82 KB

A little extra info on #62: .form--inline .form-item-separator was modified a bit. The one use I'm aware of outside of the image resolution inputs is the "or" when adding a field. This is how it now appears in seven and claro


Status: Needs review » Needs work

The last submitted patch, 62: 3082672--62.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new1.09 KB
new45.25 KB

Fixing the test failure in #62. "x" and "pixels" in the editor max dimensions were moved from prefix/suffix to their own render array elemenets in the form. This resulted them in being part of the schema config checks, so I added them to the schema with as type: ignore

katherined’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new34.82 KB
new15.85 KB

This is a partial review up to form--text.pcss.css to try to make this a bit more digestible.

1. I understand moving "x" and "pixels" to their own render array elements, but I'm not confident enough here to say whether or not there's a better way to handle the schema issue, so I would rather defer to others with more expertise there.

2.

+++ b/core/themes/claro/css/components/form--prefix-suffix.pcss.css
@@ -0,0 +1,141 @@
+.form-item__affix {
+  box-sizing: border-box;
+  border: 1px solid var(--color-lightgray);
+  background: var(--color-lightdiamond);
+}

This selector is duplicated.

3.

+++ b/core/themes/claro/css/components/form--prefix-suffix.pcss.css
@@ -0,0 +1,141 @@
+.form-item__affix {
+  display: flex;
+  overflow: hidden;
+  flex-direction: column;
+  justify-content: center;
+  padding: calc(var(--space-xs) / 2) var(--space-xs);
+  white-space: nowrap;
+}

I can't quite figure out why the overflow:hidden is necessary here, but that may just be me missing something.

4.

+++ b/core/themes/claro/css/components/form--prefix-suffix.pcss.css
@@ -0,0 +1,141 @@
+.form-item__affix--empty {
+  padding-right: 0;
+  padding-left: 0;
+}

I'm still seeing a bit of a gray box here, so I think a border:none might be a good idea.

5. At small breakpoints, and only on the "Number prefix suffix" test page, the label does not span the full width of the input element. This happens in Chrome, Firefox, and IE. See screenshot below:

6. In IE, the focus border is obscured when the prefix and suffix are stacked. See screenshot below:

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new47.39 KB
new7.26 KB

#66.1 We can have another reviewer determine if the schema approach is acceptable
#66.2 Consolidated that dupe.
#66.3 The overflow hidden keeps inputs from spilling out of the viewport in IE11 at narrow widths and is not targeted for IE11 since it's overall beneficial to have overflow enforced in this way when it's a container with several elements of different widths stacking in a variety of ways.
#66.4 Yep, it looks nicer with the border removed.
#66.5 It looks like JavaScript doesn't get the correct width of number inputs when it is styled at width: 100%. Fortunately, it looks like it would be preferable to not have number inputs at 100% width when an affix is present. I've made it so number inputs -- only when affixes are present -- have width set to auto instead of 100% at narrow widths.

katherined’s picture

Status: Needs review » Needs work

I've confirmed that the issues in #66 are addressed, and this is everything else I could find:

1.

+++ b/core/themes/claro/js/prefix-suffix.es6.js
@@ -0,0 +1,261 @@
+      $(input).on('formUpdated.machineName', prefixSuffix);
+
+
+      // When CKEditor is ready, the input widths may change. The prefixes and

Extra line.

2.

+++ b/core/themes/claro/js/prefix-suffix.es6.js
@@ -0,0 +1,261 @@
+    /**
+     * Determine the width of as affixed form input inside a table cell.
+     *

Nit: typo (an affixed?)

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new1.82 KB
new47.57 KB

Addresses #68 + a little bit of clean up and added comments.

katherined’s picture

Status: Needs review » Reviewed & tested by the community

+1 to more comments. :)

I've tested this with Firefox, Chrome, and IE, and with the form variations provided by the Prefix Suffix Claro dev tools module.

I've manually located and tested each css selector, and I can't find any additional issues.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/editor/config/schema/editor.schema.yml
@@ -40,3 +40,9 @@ editor.editor.*:
+            ex:
+              type: ignore
+              label: 'x'
+            pixels:
+              type: ignore
+              label: 'pixels'

How come config schema is changing here? These shouldn't be making it into config. If something is failing because of config schema then it means that this form elements are resulting values being saved in configuration. that shouldn't be happening here.

alexpott’s picture

Title: Form prefix/suffix redesign » Form prefix/suffix redesign in Claro

Re-titling as the scope sounds huge from the title.

lauriii’s picture

It seems like item elements get added to form state regardless of its documentation. I opened an issue for this: #3164524: Item elements are added to form state. In the mean while, we could consider using for example inline templates for rendering the form element separators.

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new3.34 KB
new47.44 KB

The schema-editing solution felt ugly when I was doing it, so very happy to get the suggestion in #73. This uses inline templates instead.

This patch has a few additional tweaks to facilitate better backwards compatibility.

lauriii’s picture

Should we open a follow-up to convert these to use #type => item once #3164524: Item elements are added to form state has landed?

katherined’s picture

Status: Needs review » Reviewed & tested by the community

This simplified approach looks great to me and works. Marking as RTBC.

quietone’s picture

Status: Reviewed & tested by the community » Needs work

Just a light review.

Great to see the manual testing done here, See #70. As a review it would be nice to have that in the issue summary.

I do see that patch has coding standard errors, https://www.drupal.org/pift-ci-job/1795540. Setting NW for that.

bnjmnm’s picture

Status: Needs work » Reviewed & tested by the community

The CSS coding standard errors are from CSSLint, which has been abandoned in favor of Stylelint, which is capable of linting the newer syntax used by Claro. The JS error is a also a known idiosyncrasy of drupalci and not indicative of an actual error. This can be confirmed by running lint:css and lint:js locally, which check against current standards. Definitely confusing, but fortunately I know that @lauriii is looking into getting drupalci updated so these inaccurate errors are not triggered. This can safely go back to RTBC.

lauriii’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new21.97 KB
new15.63 KB

A bit of feedback I have after testing the patch:


  1. I'm not sure it makes sense to apply this pattern for the generated machine name use case.

  2. While it looks good to align text to right on the fields that have a suffix, using it feels really strange. I think we should consistently align text on left when in LTR.
  3. The color contrast seems to be sufficient in terms of color contrast checkers. However, I find it quite difficult to read text in the prefix and suffix. Couldn't we increase the contrast by using a lighter shade of gray without having too much of an impact on the design?
bnjmnm’s picture

StatusFileSize
new110.24 KB
new47.57 KB
new4.1 KB

#80.1
The machine name is now explicitly un-styled with a @todo pointing to an issue I just created: #3166429: Consider moving the machine name preview element out of #suffix/#field_suffix

#80.2
Yea, the right align looks weird. Got rid of it.

#80.3
I thought it was just my cruddy display, but I thought readability was a bit tough, too. Using existing grays there's really only one other choice, so I added it to the patch for review. It does change the feel, so if this seems like a direction worth pursuing we can bring it up with design/

saschaeggi’s picture

@lauriii

While it looks good to align text to right on the fields that have a suffix, using it feels really strange. I think we should consistently align text on left when in LTR.

+1, agreed

The color contrast seems to be sufficient in terms of color contrast checkers. However, I find it quite difficult to read text in the prefix and suffix. Couldn't we increase the contrast by using a lighter shade of gray without having too much of an impact on the design?

We could use a lighter shade yes. But I'm not sold on using borders like @bnjmnm did in his approach.

ckrina’s picture

Issue summary: View changes
StatusFileSize
new4.11 KB

100% agreed with what @saschaeggi said. This big contrast between the border and the background is too much. What about something like this that we tried at the beginning?

saschaeggi’s picture

StatusFileSize
new19.2 KB

@ckrina I would just increase the text a bit more (also because of the feedback of the contrast)
Maybe like this:

White Smoke bg, Light Grey border, Davy's grey text color)

saschaeggi’s picture

Status: Needs review » Needs work
StatusFileSize
new318.2 KB

We've discussed this (@ckrina, @lauriii & @bnjmnm & I) in Slack.

I've updated the specification for this in Figma: https://www.figma.com/file/OqWgzAluHtsOd5uwm1lubFeH/Drupal-Design-system...

Also here as a screenshot:

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new120.91 KB
new1.13 KB
new47.34 KB

Thanks for the quick feedback @saschaeggi @ckrina, this looks good!

saschaeggi’s picture

That was even quicker @bnjmnm 😉💪

lauriii’s picture

Based on https://api.drupal.org/api/drupal/developer%21topics%21forms_api_referen... #field_prefix and #field_suffix could be used in checkbox, machine_name, password, password_confirm, radio, select, textarea and textfield form elements. Let's make sure that we test all of them.

I had to link Drupal 7 documentation because I couldn't find this documentation page for Drupal 8 or 9. Closest what I could find was https://www.drupal.org/docs/8/api/form-api/form-render-elements which doesn't mention #field_prefix or #field_suffix but only talks about #prefix and #suffix which are different.

saschaeggi’s picture

Issue summary: View changes

Updated the design in the issue summary

lauriii’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new143.39 KB

This also breaks Views UI path configuration for page views:

lauriii’s picture

Issue summary: View changes
bnjmnm’s picture

Assigned: Unassigned » bnjmnm
bnjmnm’s picture

Regarding #90, it looks like that views form adds incomplete spans inside field_prefix and field_suffix, but since the affixes themselves are spans, this causes all sorts of problems that happen to be more noticeable in Claro.
There was an existing Views issue for this that I just provided a patch for.
#2336569: Remove incomplete <span> usage from #field_prefix and #field_suffix

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new11.27 MB
new12.96 KB
new50.47 KB

This expands the styles so they work well with more input types. Many screenshots in the attached .zip.

Checkboxes and radios are parts of fieldsets and the styles in this issue would not work well with these kind of elements. Fortunately, they use a different template and aren't impacted by any of the changes in this issue. Screenshot attached as confirmation. If these inputs require the Claro treatment, they'd need element-specific designs and could be scoped to a different issue.

Password inputs are impacted by these styles. They don't work well at all due to how password elements are structured. These would also need to get designs specific to the type of field. For now, I added theme suggestions that have password inputs use templates that don't include the new field_prefix/field_suffix markup.

bnjmnm’s picture

Assigned: bnjmnm » Unassigned
katherined’s picture

Status: Needs review » Needs work
StatusFileSize
new41.53 KB
new23.95 KB

I see an issue with password fields.

The confirm password field shouldn't be visible until a password is entered, and the input and strength indicator are too wide.

before:

after:

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new4.95 KB
new52.23 KB

Good find on #96! Looks like the theme suggestion steps on the preprocess_form_element_HOOK calls for the password and password confirm elements. Looks like its easiest to add a template for both instead of trying to link them to the same template but not the same preprocessor.

katherined’s picture

The fix in #97 makes sense to me, and that was the only thing I found to report in #96 after reviewing the code, including the recent style updates.

I believe this is ready to RTBC when #2336569: Remove incomplete <span> usage from #field_prefix and #field_suffix is committed (it's currently RTBC).

bnjmnm’s picture

StatusFileSize
new49.28 KB
katherined’s picture

Status: Needs review » Reviewed & tested by the community

Since #2336569: Remove incomplete <span> usage from #field_prefix and #field_suffix has been committed, I believe everything is resolved sufficiently to mark this as RTBC.

ckrina’s picture

I've opened #3174118: Text area prefix/suffix on Claro as a followup to improve the designs for the text area suffix and prefix.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/editor/editor.admin.inc
    @@ -106,10 +106,13 @@ function editor_image_upload_settings_form(Editor $editor) {
    +    '#type' => 'inline_template',
    
    @@ -120,9 +123,11 @@ function editor_image_upload_settings_form(Editor $editor) {
    +    '#type' => 'inline_template',
    

    Let's add @todo that reminds that we should convert these to use #type=>item after #3164524: Item elements are added to form state has been resolved

  2. +++ b/core/modules/editor/editor.admin.inc
    @@ -106,10 +106,13 @@ function editor_image_upload_settings_form(Editor $editor) {
    +    '#template' => '<div class="form-item form--inline__separator"> × </div>',
    
    @@ -120,9 +123,11 @@ function editor_image_upload_settings_form(Editor $editor) {
    +    '#template' => '<div class="form-item form--inline__separator"> ' . t('pixels') . ' </div></div>',
    
    +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php
    @@ -151,6 +151,9 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t
    +          'class' => ['form--inline__separator'],
    
    +++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
    @@ -211,16 +211,28 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
    +        'class' => ['form--inline__separator'],
    ...
    +        'class' => ['form--inline__separator'],
    
    @@ -238,16 +250,28 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
    +        'class' => ['form--inline__separator'],
    ...
    +        'class' => ['form--inline__separator'],
    

    Should we rename this class to form-item--inline-separator to be more consistent with BEM? Or maybe we should make it a new block level class to not be dependent on form-item which is defined elsewhere.

  3. +++ b/core/themes/claro/css/components/form--prefix-suffix.pcss.css
    @@ -0,0 +1,177 @@
    + * Prefix and suffix border radii are different depending if they are next to or
    ...
    + * Remove border radii that are adjacent to a prefix and/or suffix.
    

    Nit: s/radii/radius

  4. +++ b/core/themes/claro/css/components/form--prefix-suffix.pcss.css
    @@ -0,0 +1,177 @@
    +  .form-item__wrapper--stacked-prefix .form-element.form-element:focus {
    +    margin-top: 5px;
    +  }
    +  .form-item__wrapper--stacked-suffix .form-element.form-element:focus {
    +    margin-bottom: 5px;
    +  }
    

    Why is this only needed on IE 🤔

bnjmnm’s picture

StatusFileSize
new48.85 KB
new7.47 KB

#102.1 Todos added
#102.2 Added a block level class, .form-inline-separator for both the reason you mentioned, and that the name still strongly hints that this class is at its most useful when used as a child of form--inline.
#102.3 Radii is the plural form of radius (but does look odd typed out)
#102.4 Reworded the comment to hopefully make this clearer.

bnjmnm’s picture

Status: Needs work » Needs review
katherined’s picture

Status: Needs review » Reviewed & tested by the community

The changes look good to me. The block level class name makes sense, and the comment clears things up. Moving back to RTBC.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs work

The patch does not apply anymore. I believe the CSS would need to be regenerated, etc. so not trying to hotfix it locally.

$ git apply --index 3082672-103.patch 
error: patch failed: core/themes/claro/css/base/variables.pcss.css:12
error: core/themes/claro/css/base/variables.pcss.css: patch does not apply
lauriii’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new48 KB

Reroll of #103. Also added minimumred to the dictionary to pass cspell tests.

alexpott’s picture

+++ b/core/modules/editor/editor.admin.inc
@@ -106,10 +106,15 @@ function editor_image_upload_settings_form(Editor $editor) {
+  // @todo change #type to 'item' in https://drupal.org/node/3165290
+  $form['max_dimensions']['ex'] = [
+    '#type' => 'inline_template',
+    '#template' => '<div class="form-item form-inline-separator"> × </div>',
+  ];

+++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
@@ -211,16 +211,28 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) {
+    $element['max_resolution']['ex'] = [
+      '#type' => 'item',
+      '#markup' => ' × ',
+      '#wrapper_attributes' => [
+        'class' => ['form-inline-separator'],
+      ],
+    ];

It's interesting that we're using inline template in one place and item type in another. How come we're not waiting for #3164524: Item elements are added to form state to use item everywhere?

lauriii’s picture

I believe I recommended using inline templates as a work around for #3164524: Item elements are added to form state in #73. While it is not ideal I thought it could be acceptable. However, now that I'm looking at it again, I'm a bit concerned of using this work around given that changing to type item could have BC implications.

gábor hojtsy’s picture

Status: Reviewed & tested by the community » Needs review

That sounds like at least needs discussion then.

lauriii’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Besides #108, we should probably add some test coverage for the JavaScript added here.

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.

bnjmnm’s picture

Status: Needs work » Needs review
StatusFileSize
new65.21 KB
new15.06 KB

This adds tests and a few needed adjustments that were surfaced by those tests.

Comments 8-10 here #3164524: Item elements are added to form state makes it seem like there may not be a solution for the '#type' => 'item' that doesn't have more BC implications than the inline template approach currently happening here. It's possible there's something a little less BC breaking than what we currently have, though.

fhaeberle’s picture

ckrina’s picture

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.

javi-er made their first commit to this issue’s fork.

javi-er’s picture

Hi, I just created a merge request with the latest patch (#103) to help with the review process. The changes are still mergeable (no conflicts with base branch) at this point.

ckrina’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new2.75 MB
new14.72 KB

Thanks for making it easier to test @javi-er! Everything I've tested looks great but there's a JS issue on Firefox that might need some eyes: right now the width for the prefix is being calculated on the window resize and it's causing some issues. It can be reproduced at /admin/structure/types/manage/page/fields/add-field when the prefix is triggered changing the machine name: the width is only calculated when the window is resized.

Here's a recording of the behavior:

https://www.drupal.org/files/issues/2021-06-22/prefix.mp4

javi-er’s picture

@ckrina I took a look and the width is actually calculated both on windows load and resize, the issue is that it should also be calculated again when a field becomes visible since the .visually-hidden class in the parent sets the width and height of that container to 1px which wrecks it.

To solve this, I added a listener for class changes on the parent, which is where the .visually-hidden class is located.
It will actually recalculate widths on any class changes in the parent to cover for any other future cases.

Another alternative was using drupalViewportOffsetChange event, which probably is an overkill since it will recalculate widths with any change, for instance if a fieldset is expanded.

I also changed this line https://git.drupalcode.org/project/drupal/-/merge_requests/828#note_30422 since it was throwing an error in the case of a CK Editor field with a prefix.

javi-er’s picture

Status: Needs work » Needs review

ckrina’s picture

Issue summary: View changes
Status: Needs review » Needs work
StatusFileSize
new94.92 KB
new15.52 KB
new72.31 KB
new52.18 KB

Thanks @javi-er!! I've reviewed it with modern browsers (Firefox, Chrome and Safari) and it works great but... IE11 not, sorry. The form to edit the label is not properly working and the label appears twice:

@lauriii mentioned on Slack that we have tried to support IE 11 the same way as any other browser but it might not make sense anymore given that we are dropping support for IE 11 in Drupal 10, so something along the lines of making it usable would make sense for him.

But the problem is that we end up with one extra label that makes the form confusing. This is how it should be:

So I'd say we should try to hide that extra label on IE11.

Apart from that, everything looks great. Here are some screenshots:

volkswagenchick’s picture

Issue tags: +Design4Drupal 2021

Tagging for Design4Drupal 2021. Contributions are Friday, July 22
https://design4drupal.org/

volkswagenchick’s picture

Issue tags: -Design4Drupal 2021 +Design4Drupal2021

Correcting tag Design4Drupal2021

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.

javi-er’s picture

Rebased to 9.4.x

javi-er’s picture

Status: Needs work » Needs review
StatusFileSize
new889.22 KB
new941.43 KB

I rebased this to 9.4.x and I'm not seeing the issues on Internet Explorer 11 in my local, can you confirm if it's still happening? Screenshots below.

ckrina’s picture

Status: Needs review » Needs work

Thanks @javi-er! I've checked the commit and the color changes should be adapted to the new Gray scale from #3154539: Implement new Gray scale on Claro. So this needs some color changes now.

But on the other side you're right, I don't see that issue anymore on IE.

javi-er’s picture

Status: Needs work » Needs review

@ckrina great! I just updated the colors to adjust to the new grayscale, also as part of this ticket --color-minimumred is added as well.

ckrina’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs accessibility review
StatusFileSize
new100.3 KB
new48.25 KB
new58.47 KB

Thanks @javi-er! On a design perspective this looks great!

I've taken a look into the code and I've found a few things, so I've left a few comments on the MR.

Also, I've found a place that is still not looking good, mentioned already in comment #90: /admin/structure/views/view/comment. See in Seven:

While in Claro:

I've updated the testing instructions too.

javi-er’s picture

Status: Needs work » Needs review

@ckrina hi! I addressed your comments in the MR.

Regarding the view page path prefix issue, it seems to be an issue with Views actually, since it's adding some HTML to the prefix without checking if there is a value, see: https://git.drupalcode.org/project/drupal/-/blob/9.4.x/core/modules/view...
which ends up with an empty prefix with just a "&lrm;" marker on it. Although the problem seems to be that in that line, the site URL should be placed. In any case, this should be addressed in a separate ticket.

mherchel’s picture

Status: Needs review » Needs work

Looks like the JavaScript needs to be recompiled

$ cross-env BABEL_ENV=legacy node ./scripts/js/babel-es6-build.js --check --file /var/www/html/core/themes/claro/js/prefix-suffix.es6.js
[18:18:28] '/var/www/html/core/themes/claro/js/prefix-suffix.es6.js' is being checked.
[18:18:28] '/var/www/html/core/themes/claro/js/prefix-suffix.es6.js' is not updated.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

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

andregp’s picture

Status: Needs work » Needs review

Recompiled the JavaScript file to address #137

mherchel’s picture

Status: Needs review » Needs work

Looks like we also need to recompile the CSS. It was probably like that before, but I just saw the one failure and didn't look further. Sorry!

 yarn run v1.22.17
$ node ./scripts/css/postcss-build.js --check --file /var/www/html/core/themes/claro/css/components/form.pcss.css
[20:35:27] '/var/www/html/core/themes/claro/css/components/form.pcss.css' is being checked.
[20:35:27] '/var/www/html/core/themes/claro/css/components/form.pcss.css' is not updated.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
STYLELINT: core/themes/claro/css/components/form.pcss.css passed
 
andregp’s picture

Status: Needs work » Needs review

@mherchel no problem :)

Recomplied the css files.

deviantintegral’s picture

I can no longer replicate the issue on 9.4.x on the site information form, but I can on the image toolkit settings. Regardless, this design is a nice improvement!

To review the testing steps (macOS Safari 15, 560px width):

Passed

  • Visit /admin/config/system/site-information and verify the Default front page field.
  • Test it working with the focus design (using the keyboard to navigate to this field, for example).
  • Visit /admin/config/media/image-toolkit and verify the JPEG quality field.
  • Navigate to /admin/structure/types/manage/page/fields and start adding a field. Before saving it, edit the machine name.The preffix "field" should look like a preffix.
  • Test the focus working fine with the error.
  • Add several combinations of Number fields with Prefix and suffix, and multiple fields too.

Failed

  • Enter a wrong machine name (like add and space in the middle) and verify the error looks as in the designs.
    • This doesn't look bad but certainly doesn't match the figma designs. There's too much spacing, and there's no inline error text.
    • Invalid machine name error
  • Visit /admin/structure/views/view/comment and click on edit Path under "Page settings". The field path on the dialog should look OK (no prefix).
    • This is not fixed yet
    • View path prefix
  • Visit /user/1/edit and edit the Password field. The confirm password field shouldn't be visible until a password is entered, and the input and strength indicator shouldn't be too wide. (Per comment #66).
    • This is not fixed yet at >616px
  • New bug: If I change the width while a collapsed fieldset is closed, and then open the collapsed fieldset, the prefix does not get restyled. For example, collapse "Front page" in Basic site settings, resize, and then open it again. I confirmed this in both Safari and Firefox.
andregp’s picture

Status: Needs review » Needs work

Needs work for #142
@deviantintegral, thanks for the detailed review.

deviantintegral’s picture

Status: Needs work » Needs review

I reviewed the PHP and JS side of things. Very minor notes, that are of a "take it or leave it" variety. Nice work so far!

deviantintegral’s picture

Status: Needs review » Needs work
javi-er’s picture

Regarding this comment from @deviantintegral for one of the issues:

Visit /admin/structure/views/view/comment and click on edit Path under "Page settings". The field path on the dialog should look OK (no prefix).

I pointed above that it seems to be an issue with Views actually, since it's adding some HTML to the prefix without checking if there is a value, see: https://git.drupalcode.org/project/drupal/-/blob/9.4.x/core/modules/view...
which ends up with an empty prefix with just a "&lrm;" entity on it. (Although the problem seems to be that Url::fromRoute('<none>', [], ['absolute' => TRUE])->toString() it's returning an empty string). In any case, should this be addressed in a separate ticket for Views and not for Claro?

javi-er’s picture

Also regarding this point on comment #142:

Enter a wrong machine name (like add and space in the middle) and verify the error looks as in the designs.
This doesn't look bad but certainly doesn't match the figma designs. There's too much spacing, and there's no inline error text.

Isn't this also a separate issue? there are two problems here but none seems to be on the scope of the prefix and suffix redesign:

  1. The spacing between the field title and input is indeed bigger than the Figma design, but this is also happening in non-prefixed fields like the one immediately above (Label)
  2. Errors aren't displayed inline but at the top, shouldn't this be done as a separate ticket for moving all error messages inline?
javi-er’s picture

StatusFileSize
new91.15 KB

Continuing with points mentioned in #142:

Visit /user/1/edit and edit the Password field. The confirm password field shouldn't be visible until a password is entered, and the input and strength indicator shouldn't be too wide. (Per comment #66).
This is not fixed yet at >616px

I couldn't reproduce this, in my local the password confirm field is showing up after I enter a password, also in any case isn't this too a separate issue than suffix and prefix redesign?

javi-er’s picture

StatusFileSize
new1.01 MB

Regarding the last point on #142:

New bug: If I change the width while a collapsed fieldset is closed, and then open the collapsed fieldset, the prefix does not get restyled. For example, collapse "Front page" in Basic site settings, resize, and then open it again. I confirmed this in both Safari and Firefox.

This was addressed in the merge request, but it was incorrect. I replaced MutationObserver with IntersectionObserver so it looks for actual visibility changes in the element instead of class changes in the wrapper parent.

deviantintegral’s picture

CI checks are passing for me locally. There's been ckeditor changes in 9.4.x, let's see if merging clears them up.

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

javi-er’s picture

Status: Needs work » Needs review

I addressed the last two comments in the MR, I'm moving this to "needs review" since the errors in the tests doesn't seems to be related to these changes, please move it back to "needs work" otherwise.

ckrina’s picture

Status: Needs review » Needs work

Moving to Need work because of the test failures.

deviantintegral’s picture

StatusFileSize
new767.54 KB

I've pushed up a fix for the kernel test, and updated against 9.4.x.

For the remaining javascript failures, I have got as far as replicating the issue. It looks like the

form-item__affix--stacked

(and the corresponding suffix) classes are not being applied to the form:

affix class missing

I likely won't get more time this week to dive into the actual fix for it, so someone else is welcome to pick this up.

deviantintegral’s picture

Status: Needs work » Needs review
deviantintegral’s picture

Tests passed, and from my perspective all of the review notes I left are resolved. It looks like I don't have permission to actually mark them resolved in GitLab.

javi-er’s picture

Thanks @deviantintegral ! I just marked all comments as resolved in the MR.

javi-er’s picture

Issue summary: View changes

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.

javi-er’s picture

Status: Needs review » Reviewed & tested by the community

Moving this to RTBTC in hope of move it forward, since all the issues that were found are addressed now.

mherchel’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new425.7 KB
new45.2 KB

Thanks for the excellent work on this @javi-er. I did a followup review at the request of @lauriii, and found a couple issues above.

In addition to those:

There's a prefix in front of the views path. Is this intentional?

RTL styling isn't complete

It's looking really good, though. If I have time later this weekend, I'm going to continue to look through the code (I really haven't yet) and maybe push up some fixes.

javi-er’s picture

Status: Needs work » Needs review

Thanks @mherchel! I fixed the two issues you noticed in the MR.

Regarding the empty prefix you noticed in front of the Views path, I think this is a bug that needs to be addressed as a Views issue actually, see comment #146 above.

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.

nod_’s picture

Status: Needs review » Needs work

The merge request should be updated/recreated against 10.1.x branch.

lauriii’s picture

Status: Needs work » Needs review
StatusFileSize
new72.38 KB

Rerolled for 10.1.x.

lauriii’s picture

Status: Needs review » Needs work
StatusFileSize
new10.24 KB

There's a regression to the bulk operations form with #165. The "Action" label should be displayed inline.

srishtiiee’s picture

StatusFileSize
new72.83 KB
new464 bytes
new26.07 KB

srishtiiee’s picture

StatusFileSize
new72.57 KB
new1.3 KB
gauravvvv’s picture

Status: Needs work » Needs review
StatusFileSize
new77.24 KB
new1.02 KB

Fixed the build and regression bug. Attached interdiff for same. please review

Status: Needs review » Needs work

The last submitted patch, 169: 3082672-169.patch, failed testing. View results

bnjmnm’s picture

Even as someone who put a ton of work into this a few years back, I'm not sure this should go in as-is due to the many ways that #prefix/#suffix is used. This is a very opinionated style, and is great for things like adding a currency symbol before a "cost" field or "https://sitename/" before a relative path field.

There are many valid uses for #prefix/#suffix beyond these field-decorating ones. Several are successfully addressed in this issue, but it also strongly suggests that many contrib and custom modules use #prefix/#suffix in ways that would be disrupted by this change to Claro. Perhaps the flexibility of #prefix/#suffix makes this kind of styling prohibitively complex, but that flexibility has also made it possible to introduce valuable functionality.

I do like these styles, though. My thought is to make them opt-in, perhaps via an additional render array property. This way, fields that benefit from them can do so, but we can avoid surprises like #166, #161, #142, #135, #125, #96 etc, etc.

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.

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.