0

I've managed to add a second action to the actions column in the admin product listing. It works fine until I add another column to the display. The dropdown menu doesn't "follow" the actions column and stays on the right : enter image description here

Is there any way to fix this ? I'm running Magento 2.3.3

EDIT

Here's my code

etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
  <!-- Plugin that adds an action to the default admin panel product listing -->
  <type name="Magento\Catalog\Ui\Component\Listing\Columns\ProductActions">
    <plugin name="pluginname" type="Vendor\Module\Plugins\AddStatsActionToProductListing" sortOrder="1" disabled="false" />
  </type>
</config>

Plugin Class

public function afterPrepareDataSource(\Magento\Catalog\Ui\Component\Listing\Columns\ProductActions $subject, $result)
{

    foreach ($result['data']['items'] as &$item) {
        $item[$subject->getData('name')]['stats'] = [
            'href' => $this->_urlBuilder->getUrl(
                'vendor_module/groups_perproduct/index',
                ['product_id' => $item['entity_id']]
            ),
            'label' => __('Stats'),
            'hidden' => false,
            '__disableTmpl' => true
        ];
    }

    return $result;
}
2
  • Could you update the code? – Jimmy Apr 15 at 1:25
  • @Jimmy Thanks for asking, I uploaded my code – Gautier Bardon Apr 15 at 7:31
0

I checked the code, the Action column seems be meant to be the last column.

The reason you have this is because the list actions, <ul> tag is positioned absolute, whereas the closest relative element is .admin__data-grid-outer-wrap, so the ul's position will be aligned with that relative element.

No matter what the last column is, the ul will always be there, at that specific position

2
  • Oh I see it makes sense. It's kinda weird that magento makes it possible to add columns to the right of the action's column. I guess the solution would be to have a custom column that replaces the action one, with the same layout ? I believe that's possible. – Gautier Bardon Apr 15 at 9:03
  • you could add as many columns as you want, just position them before Action column to make it displays correctly. – Jimmy Apr 15 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.