The code in question:

/**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $actions = array();
    foreach ($this->manager->getDefinitions() as $id => $definition) {
      if (is_subclass_of($definition['class'], '\Drupal\Core\Plugin\PluginFormInterface')) {
        $key = Crypt::hashBase64($id);
        $actions[$key] = $definition['label'] . '...';
      }
    }

The ... string appended to action label does not serve any purpose, and it is not translatable.

Proposed resolution

Remove hardcoded string.

Before

After

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hass created an issue. See original summary.

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

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now 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.

Prashant.c’s picture

Status: Active » Needs review
FileSize
1.04 KB

Adding patch to truncate the label although not sure about what $max_legth should be given, for now i have hard-coded it to 30.

naveenvalecha’s picture

Category: Bug report » Feature request

I believe this would be the feature request as everything works fine and nothing broken.

hass’s picture

Category: Feature request » Bug report

No it's not. It is a not used Drupal API and these are bugs.

20th’s picture

Priority: Normal » Minor
Issue tags: +ui-text
FileSize
724 bytes

Actually, the label here is not being truncated, the ellipsis is just being appended to it without any apparent reason...

It looks like this code has been around for a while:

  • originally added by #148410: Actions in core to modules/actions/actions.module file back in 2007;
  • then copy-pasted into modules/system/system.admin.inc file;
  • survived several refactorings while being moved around a lot;
  • then moved into core/modules/system/system.admin.inc when D8 development started;
  • copy-pasted into core/modules/action/action.admin.inc;
  • then copy-pasted into core/modules/action/lib/Drupal/action/Controller/ActionController.php;
  • which eventually became core/modules/action/src/Form/ActionAdminManageForm.php.

If we truncate action label here, we will have to truncate it in every other place where it is displayed, for consistency. This string cannot be very long anyway. I suggest that we simply remove the ellipsis.

hass’s picture

I'm fine with removing ellipsis, too. Is there really enough space for the label on all devices?

20th’s picture

Actions are defined as plugins with the help of annotations. For example:

<?php

/**
 * Publishes a node.
 *
 * @Action(
 *   id = "node_publish_action",
 *   label = @Translation("Publish selected content"),
 *   type = "node"
 * )
 */
class PublishNode extends ActionBase {

This way the length of action labels is limited by Drupal coding standards, so it cannot be very long.

Furthermore, the list of actions is displayed in a select list and on mobile defices it will be rendered with a native UI widget that can properly handle long strings.

So I think, there won't be any problems with the space.

20th’s picture

Title: Label is not using Unicode::truncate() » Hardcoded ellipsis in actions configuration form
Issue summary: View changes
20th’s picture

Issue summary: View changes

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

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.

Munavijayalakshmi’s picture

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

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now 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.

Chi’s picture

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

The patch no longer applies to 8.x.5. Probably because of #2911806: Remove unnecessary Crypt::hashBase64() call from Action UI.

harsha012’s picture

Status: Needs work » Needs review
FileSize
697 bytes

re-rolled the patch

hass’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs reroll
alexpott’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs usability review
FileSize
97.86 KB
97.65 KB

Here's a screenshot of the affected select list.

And after the patch is applied:

One thing this does bring up is that we're slightly reducing the usability here because the selectable options before always added a ... and now the empty option Choose an advanced action looks like all the others. The default empty text for a required field is select is - Select -. Adding the - makes it look different. I think we should discuss changing the #empty_option to - Select - because in the context of the CREATE AN ADVANCED ACTION box on a select empty labelled Action I'm not sure that the text Choose an advanced action actually adds anything.

I'll ping the @yoroy as the product manager with the most usability experience to make a call.

Removing the fake ellipsis is definitely the right thing to do.

  • xjm committed 62b010e on 8.5.x
    Issue #2763433 by 20th, harsha012, Munavijayalakshmi, Prashant.c, hass:...
xjm’s picture

Issue summary: View changes
Status: Needs review » Fixed
FileSize
75.01 KB
72.79 KB

Thanks @20th for documenting the history of why the ellipsis was there in the first place; that's always really helpful.

It took me a bit of hunting to find where this ellipsis actually was. On /admin/config/system/actions, it's in the "Create an advanced action" fieldset at the bottom of the page, appended to each item in the select list:

So I agree it is fine to just remove this. With the patch applied:

Committed to 8.5.x. It's not a string change, but it is a slight change to the UI, so I didn't backport it for now.

Thanks all!

xjm’s picture

Crossposted with #17. I don't think this issue is regressing that, because "Choose an advanced action" already looked exactly the same as the other options regardless. I'd propose a followup issue for that.

xjm’s picture

Not reverting for now. Feel free to revert it for more discussion if you feel strongly about it, but I don't think it's necessary for the reasons in #20.

Chi’s picture

alexpott’s picture

Issue tags: -Needs usability review

Re #20 - works for me. I debated whether a followup was okay when writing #17. I went with no because I thought they might be a very small usability regression but happy that #2917916: Improve usability of create action dropdown has been filed.

Status: Fixed » Closed (fixed)

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