1

I want to show account information tab as active,

when admin goes to customer edit page. By default it shows customer view tab as active.

I checked Magento Ui module but still no luck. Is there anyone who did this type of customisation.

Appreciate if anyone can help!!

2

I found the solution in

vendor/magento/module-ui/view/base/web/js/form/components/tab_group.js.

There is one function called which activates first tab by default.

/**
 * Activates element if one is first or if one has 'active' propert
 * set to true.
 *
 * @param  {Object} elem
 * @returns {Object} - reference to instance
 */
initActivation: function (elem) {
    var elems   = this.elems(),
        isFirst = !elems.indexOf(elem);

    if (isFirst || elem.active()) {
        elem.activate();
    }

    return this;
},

I just changed that condition as I needed like below

/**
 * Activates element if one is first or if one has 'active' propert
 * set to true.
 *
 * @param  {Object} elem
 * @returns {Object} - reference to instance
 */
initActivation: function (elem) {
    var elems   = this.elems(),
        isFirst = !elems.indexOf(elem);

    if (elem.index == 'customer' && elem.ns == 'customer_form') {
        elem.activate();
    } else if (isFirst || elem.active()) {
          elem.activate();
    }

    return this;
},

Make sure you override this file. Hope it will help others. Happy Coding :)

  • 1
    I think it will affect all the tabs...Add else condition with default code – Ranganathan Nov 2 '19 at 10:47
  • I don't think so it will affect other tabs because at a time only one tab will be activated. But it is good to have else condition. – Ramkishan Suthar Nov 2 '19 at 10:50
  • Other tabs like order edit page tabs and so on. – Ranganathan Nov 2 '19 at 10:50
  • Thanks @Ranganathan, I just updated answer. I will check further if any improvement is there I will update my answer. – Ramkishan Suthar Nov 2 '19 at 10:56
  • Accept your answer. It will help others – Ranganathan Nov 2 '19 at 10:57

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.