I use the code below to add after order_info tab, but I want when I display the order details the active tab to be order_info.

<referenceBlock name="sales_order_tabs">
  <action method="addTabAfter">
    <argument name="name" xsi:type="string">name</argument>
    <argument name="block"xsi:type="string">VENDOR\MODULE\Block\Adminhtml\Order\View\Tab\Custom</argument>
    <argument name="after" xsi:type="string">order_info</argument>

I found the solutions!

It was in Controller Action on execute function was set


and after I removed, the order_info remain selected tab

Bellow it is my code for execute function

public function execute(){

    $layout = $this->layoutFactory->create();
    // Yes, this is the same block class that we defined in sales_order_view.xml
    $html = $layout->createBlock('VENDOR\MODULE\Block\Adminhtml\Order\View\Tab\Custom')
    // $this->_translateInline->processResponseBody($html);
    /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
    $resultRaw = $this->resultRawFactory->create();
    return $resultRaw;
| improve this answer | |

Just make sure your module loads after Magento_Sales

Add the following code into your module.xml for this:

<module name="Vendor_Module" setup_version="2.0.0">
        <module name="Magento_Sales"/>
| improve this answer | |

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.