Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#19 | no_ellipsis.png | 72.79 KB | xjm |
#19 | action_ellipsis.png | 75.01 KB | xjm |
#15 | 2763433-15.patch | 697 bytes | harsha012 |
#12 | 2763433-12.patch | 719 bytes | Munavijayalakshmi |
#6 | 2763433-6.patch | 724 bytes | 20th |
Comments
Comment #3
Prashant.cAdding patch to truncate the label although not sure about what
$max_legth
should be given, for now i have hard-coded it to30
.Comment #4
naveenvalechaI believe this would be the feature request as everything works fine and nothing broken.
Comment #5
hass CreditAttribution: hass commentedNo it's not. It is a not used Drupal API and these are bugs.
Comment #6
20th CreditAttribution: 20th commentedActually, 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:
modules/actions/actions.module
file back in 2007;modules/system/system.admin.inc
file;core/modules/system/system.admin.inc
when D8 development started;core/modules/action/action.admin.inc
;core/modules/action/lib/Drupal/action/Controller/ActionController.php
;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.
Comment #7
hass CreditAttribution: hass commentedI'm fine with removing ellipsis, too. Is there really enough space for the label on all devices?
Comment #8
20th CreditAttribution: 20th commentedActions are defined as plugins with the help of annotations. For example:
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.
Comment #9
20th CreditAttribution: 20th commentedComment #10
20th CreditAttribution: 20th commentedComment #12
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound commentedRerolled the patch.
Comment #14
Chi CreditAttribution: Chi commentedThe patch no longer applies to 8.x.5. Probably because of #2911806: Remove unnecessary Crypt::hashBase64() call from Action UI.
Comment #15
harsha012 CreditAttribution: harsha012 as a volunteer and at Red Crackle commentedre-rolled the patch
Comment #16
hass CreditAttribution: hass commentedComment #17
alexpottHere'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 optionChoose 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 theCREATE AN ADVANCED ACTION
box on a select empty labelledAction
I'm not sure that the textChoose 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.
Comment #19
xjmThanks @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!
Comment #20
xjmCrossposted 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.
Comment #21
xjmNot 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.
Comment #22
Chi CreditAttribution: Chi commentedCreated a followup #2917916: Improve usability of create action dropdown.
Comment #23
alexpottRe #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.