Skip to content

Mixin js not loading when Switch Tab while loading site #14118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sunilit42 opened this issue Mar 15, 2018 · 24 comments
Closed

Mixin js not loading when Switch Tab while loading site #14118

sunilit42 opened this issue Mar 15, 2018 · 24 comments
Labels
Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@sunilit42
Copy link
Contributor

sunilit42 commented Mar 15, 2018

Preconditions

  1. Magento 2.2.*
  2. Open Multiple Tabs in browser
  3. Create one mixins file

Steps to reproduce

  1. open your site (open your developer console)
  2. switch to another tab
  3. after finish load step 1 site go to there
  4. In console you can check no mixins js load

Expected result
It should be load all mixins js file.

Actual result
It is not loading mixins js

For example we are creating mixins for

var config = {   
	config: {
		mixins: {
			'Magento_Catalog/js/catalog-add-to-cart': {
				'NameSpace_ModuleNaame/js/catalog/catalog-add-to-cart-mixins': true
			}
		}
	}
};

catalog-add-to-cart-mixins.js code

define([
	'jquery'
], function($) {
	'use strict';

	return function (widget) {
		$.widget('mage.catalogAddToCart', $.mage.catalogAddToCart, {
			enableAddToCartButton: function (formElement) {
				this._super(formElement);
				if(formElement.attr('id') == 'product_addtocart_form') {
					$("html, body").animate({ scrollTop: 0 }, "slow");
				}
			}
		});
		return $.mage.catalogAddToCart;
	}
});

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Mar 15, 2018
@paragpadsumbiya
Copy link

@sunilit42 Thanks for reporting . After add any file you if you are in developer mode you need to run Grunt again or if you are in production mode you need to below steps to reflect your code .

rm -rf var/di var/generation var/cache var/pagecache
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy

@sunilit42
Copy link
Contributor Author

@paragpadsumbiya js and css loading properly.

It is mixin js issue.

we are extending js functionality, that js does not load when we switch tab while page load.

If you are not switching tab then works.

@sunilit42
Copy link
Contributor Author

@magento-engcom-team

Any update on this?

@magento-engcom-team magento-engcom-team added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch labels Mar 16, 2018
@magento-engcom-team
Copy link
Contributor

@sunilit42 , thank you for your report.
We were not able to reproduce this issue by following the steps you provided. Please provide more detailed steps to reproduce or try to reproduce this issue on a clean installation.

@sunilit42
Copy link
Contributor Author

Hey,

have you created mixins file?

Open Multiple Tab into your browser.
Open developer console as well
Open your magento2 site, and switch to other tab
Go to Magento 2 site tab, and check network panel into console, you will see mixin file does not call.

Hope it will help you find that problem.

@emil-vdc
Copy link

emil-vdc commented Apr 5, 2018

@magento-engcom-team

We noticed this behaviour also on Magento 2.2.0 and 2.2.2. (different sites)

When you open a page in the background tab or reload a page in the background tab the javascript mixins will not get loaded.

Steps to reproduce:

  1. Make sure you have a Javascript mixin registered
  2. Check that the mixin is loaded in the network tab in devtools
  3. Open some page that uses the mixin as a new tab and don't visit it until it is fully loaded
  4. Open and check the network tab if the custom mixins are loaded

Attached a video clip:
mixin-disappears.mp4.zip

@sunilit42
Copy link
Contributor Author

Hello @magento-engcom-team

Have you checked @emil-tw video clip.

Any update on this issue?

@JuteSenthil
Copy link

JuteSenthil commented Apr 24, 2018

Hi Team,

I am also facing same kind of issue. Please share if you have any solution.

Package: Magento ver. 2.0.8
Browser : Chrome 64.0.3

Steps to re-reproduce the issue:

Browser Tab : 1 - Adding product to cart from Product detail page (after product added to cart, the page redirect to cart page)
Browser Tab : 1 - On clicking "Go to Checkout" button, before the page redirect to checkout page meanwhile opening a new empty Tab (Tab:2) or my website in another one tab.
Browser Tab : 2 - On Tab : 2 surfing some time & go back to visit Tab : 1.
Browser Tab : 1 - Following mixin js files are not loaded fully. place-order-with-comments-mixin.js , place-order-mixin.js. If i reload the page once again then the mixinJS files are loading properly.

Thanks.

@sunilaccorin
Copy link

@magento-engcom-team

Any update on this?

@magento-engcom-team magento-engcom-team removed Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Progress: needs update labels May 26, 2018
@sunilaccorin
Copy link

Hey @magento-admin

any update on that?

@DB-Alex
Copy link

DB-Alex commented May 30, 2018

We have the same issue, would like an update asap!

@ghost ghost self-assigned this Aug 2, 2018
@ghost
Copy link

ghost commented Aug 22, 2018

Hi @sunilit42 I'm not able to reproduce following steps you describe. the problem you are described maybe relevant to web browser, we are closing this issue, If you'd like to update it, please reopen the issue.
mixingjs

@ghost ghost closed this as completed Aug 22, 2018
@sunilit42
Copy link
Contributor Author

Hello,

@magento-engcom-team checkout page comes using ajax and ko so works

Try to create one mixin for product page and try it

@ghost
Copy link

ghost commented Aug 22, 2018

@sunilit42 ok.

@ghost ghost reopened this Aug 22, 2018
@sunilit42
Copy link
Contributor Author

let me know if you want sample module

@ghost
Copy link

ghost commented Aug 22, 2018

@sunilit42 Same result for custom module, Can you please provide your module ?
selection_060

@sunilit42
Copy link
Contributor Author

just open url and switch to another tab

@ghost
Copy link

ghost commented Aug 22, 2018

@sunilit42
jsmixins

@ghost
Copy link

ghost commented Aug 22, 2018

@sunilit42 Can you reproduce this again ? or i can close issue ?

@ghost
Copy link

ghost commented Aug 23, 2018

@sunilit42 we are closing this issue. If you'd like to update it, please reopen the issue.

@ghost ghost closed this as completed Aug 23, 2018
@pravalitera
Copy link

Same issue.

Preconditions;

  • using Magento 2.1 or 2.2 (not tested on 2.3)
  • must be a human that really wants to solve problem and not closing as much as ticket as possible with "can't reproduce" tag

Steps to reproduce :

  1. Create a module with the following mixin:
var config = {
    'config': {
        'mixins': {
            'Magento_Catalog/js/price-box': {'Namespace_Module/js/price-box': true}
        }
    }

The JS :


define([
    'jquery',
    'Magento_Catalog/js/price-utils',
    'underscore',
    'mage/template',
    'jquery/ui'
], function ($, utils, _, mageTemplate) {
    'use strict';

    return function (priceBox) {
        return $.widget('mage.priceBox', priceBox, {
            reloadPrice: function reDrawPrices() {
                console.log("reloadPrice REWRITTEN ");

            }
        });
    };
});

3: Open a category page with a product Configurable.
4: donc left-click , open the link in a new tab. DON'T FOCUS IT
5: the console log won't appear

@atsareva
Copy link

atsareva commented Jan 8, 2020

I faced with the same issue on magento 2.3.3 using production mode.

@lano-vargas
Copy link

lano-vargas commented May 21, 2020

Having same issue 2.3.5 with mixins set-shipping-information just followed this tutorial from magento docs. ref:https://devdocs.magento.com/guides/v2.3/howdoi/checkout/checkout_new_field.html

I can see the mixin file added to requirejs-config.js file and I can open in the browser but the mixin file doesn't load in the checkout page. map loads fine but not mixins

var config = {
    config: {
        mixins: {
            'Magento_Checkout/js/action/set-shipping-information': {
                'Vendor_Module/js/action/set-shipping-information-mixin': true
            }
        },
    "map": {
        "*": {
            'Magento_Checkout/js/model/shipping-save-processor/default': 
            'Vendor_Module/js/model/shipping-save-processor/default'
        }
    }
}

UPDATE: Not sure if is browser issue but after open incognito the can see it loaded the mixin then just went back to default browser mode and it now loaded, so just in case anyone having same issue give it try.

@Mecalux-Developer
Copy link

Mecalux-Developer commented Aug 20, 2020

Same issue in Magento 2.3.4-p2
We have created a new issue #29694

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests