Problem/Motivation

During the usability sessions, some participants struggled to figure out how to add multiple key|label values. Some didn't understand the relationship between the key and the label.

In good form design, we use the correct input types to provide guidance towards the expected input, a large freetext area is not intuitive and requires a lot of help text to understand.

Proposed resolution

Replace the text area with multiple inputs, automatically creating the value based on the machine name UI component.

Remaining tasks

Implement the suggestions
Design review
Test

User interface changes

Better widget than textarea for managing the list items. Something similar to https://www.drupal.org/project/options_element

API changes

None

Data model changes

None

Issue fork drupal-2521800

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mErilainen’s picture

Issue summary: View changes

This will most likely require an API change if done properly. Otherwise a transformation between an array and textarea has to be made like in the Options Elements module which I linked now to the issue description.

yched’s picture

IIRC @quicksketch had a contrib module which provided a UI pattern for those kind of needs.

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

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tkoleary’s picture

Issue tags: +sprint
dmsmidt’s picture

The proposal makes key|label entry much understandable than it is currently. Maybe we can even make it more clear by not mentioning 'key' at all, but just naming it 'value'. That said, I miss the 'Remove value' options per row in the image.

The descriptions says we add certain markup (is this still so?), I would say we shouldn't advertise it when the 'simple' widget is used.
So maybe we can also have an advanced widget (the current one) as well. Because bulk entry also seems tiresome with the 'simple' widget.
If we support both we would need a toggle for the two input modes.

tkoleary’s picture

With select2 you can have a free text tag that transforms to a dismissable pill. Yet another reason to get that library into core.

dmsmidt’s picture

@tkoleary that lib is similar to Chosen right?

tkoleary’s picture

Right, but a bit more robust and well adopted

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

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

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

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

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

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

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

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

lauriii’s picture

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

lauriii’s picture

Implemented a prototype based on the proposed solution in the issue summary. The code definitely still needs clean-up, and it completely fails into taking into account other list field types.

There's probably still some minor modifications we should make to the UX. We should at least consider implementing a delete button for a row. This would improve the UX as without the delete button it's quite tedious to remove an option. We also could potentially disable the delete button when there's existing data since in this case options cannot be removed anymore.

tim.plunkett made their first commit to this issue’s fork.

tim.plunkett’s picture

Tweaked just enough to get tests to run, and then looked into the failures. Lots of "settings[allowed_values]" not found.

Also this could use #parents on the label/key fields to strip out all the table/item noise of those keys, but not doing that until we're more certain about the direction.

tim.plunkett’s picture

Issue tags: +Field UX
tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett

Working on this

Wim Leers’s picture

The same usability problem exists for:

  1. \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Style
  2. and soon also \Drupal\ckeditor5\Plugin\CKEditor5Plugin\CodeBlock

— see #3282233-34: Ability to configure additional languages (e.g. "bash" or "SQL") for CKEditor 5 CodeBlock plugin.

P.S.: see \Drupal\ckeditor5\Plugin\CKEditor4To5Upgrade\Core::mapCKEditor4SettingsToCKEditor5Configuration() and \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Style::parseStylesFormValue() for how we dealt with the transition from storing the configuration in this exact way to something more structured 🤓

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned

I was not able to work on this more since my last commit.

Thanks for the pointers @Wim Leers!

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

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

srishtiiee’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative

Seems to be several open threads on the MR

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

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.

Utkarsh_33’s picture

Status: Needs work » Needs review
srishtiiee’s picture

Status: Needs review » Needs work
Utkarsh_33’s picture

Status: Needs work » Needs review
smustgrave’s picture

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

The screenshots in the issue summary appear to be outdated.

Did find it odd that when I added a field that it made 6 value fields by default. Shouldn't it just be 1 and allow users to add more as needed?

Also should the help text be moved to the top?

Referring to this

The name will be used in displayed options and edit forms.
The value is automatically generated machine name of the name provided and will be the stored value.

Wasn't super clear where or how the value is set, or that I could edit the machine name if I wanted to update the value of the option.

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

hooroomoo’s picture

Issue summary: View changes
Issue tags: -Needs screenshots
FileSize
297.66 KB
252.02 KB

Updated issue summary with current screenshots

vasike’s picture

Status: Needs work » Needs review

i think this needs a "little review" ... at least to be checked what's left to be done ... if not "ready".

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

My points from #38 appear to have been addressed

Retested on 11.x
Added a list to the Article content type
Verified I see 1 field by default
Added a label and edited the machine name to something completely different
Added a second value
Created an Article
Inspecting the dropdown the labels and values match exactly what I did.

Also applied the patch back n forth and the list field updated without issue.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work

Discussed with @ckrina and she liked the improvement. However, she mentioned that it would be nice if we could display the float and integer fields side by side. Let's research if something that we could do easily because it seems like it would be a nice way to take this a step further 👍

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

narendraR’s picture

Status: Needs work » Needs review

Addressed #43 feedback.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed the change in #43. Excited to see this land!

srishtiiee’s picture

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

Title: List(text) key|label entry field is freetext, which doesn't give guidance towards the expected input. » List key|label entry field is textarea, which doesn't give guidance towards the expected input

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

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Retested with List(text), Floats, ints and no new issues to report.

bnjmnm’s picture

Status: Reviewed & tested by the community » Needs work

This is looking good! I opened a few threads in the MR that should be addressed but it's probably all pretty simple stuff.

narendraR’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Points appear to have been addressed.

bnjmnm’s picture

This MR was not very accommodating to a rebase so here's the 11x as a patch.

bnjmnm’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Was about to commit based on review/rtbc then noticed #43 which mentions

Discussed with @ckrina and she liked the improvement. However, she mentioned that it would be nice if we could display the float and integer fields side by side. Let's research if something that we could do easily because it seems like it would be a nice way to take this a step further 👍

I'd like to at least clarify what that is asking for and see if it was in fact considered. I believe @lauriii will be around Monday to clear this up. Setting to postponed as it's possible this might not need additional work. If we decide to not pursue that change this can go back to RTBC.

bnjmnm’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

Looking at the commit history I now see what was meant by the statement I wondered about in #55, and it has been completed satisfactorily.

  • bnjmnm committed 693ced9c on 11.x
    Issue #2521800 by srishtiiee, bnjmnm, tim.plunkett, narendraR, lauriii,...
bnjmnm’s picture

Status: Reviewed & tested by the community » Fixed

I made some minor tweaks (its all in the history, and now this is committed to 11.x (which means it'll first appear in 10.2.

Really great improvements here, and its just ambitious enough that it is good for this to be at the beginning of a new release cycle.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

quietone’s picture

Issue tags: +Needs change record
quietone’s picture

I meant to leave a comment.

This issue introduce a deprecation in \Drupal\options\Plugin\Field\FieldType\ListItemBase::extractAllowedValues and thus needs a change record. This is blocking #3048495: Fix Drupal.Semantics.FunctionTriggerError coding standard.

lauriii’s picture

quietone’s picture

Issue tags: -Needs change record

@lauriii, Thank you!

catch’s picture

The changes to ListStringItem to use machine name break when there is existing data on a site that doesn't match the machine name format. Opened #3411419: Regression from #2521800: using machine name element for ListStringItem breaks with existing data to revert just that bit.

mglaman’s picture