Open
Description
Maybe need additional fixes on #25587 request.
Preconditions (*)
- Magento 2.4.x
- Google Chrome 92 (cache disabled on devtools)
Steps to reproduce (*)
- Fresh install m2 2.4.4 (also problem with all 2.4.x)
- Dev mode on
- Cache settings (all on, except for layout, block_html, full_page)
- Create new theme (luma parent)
requirejs-config.js
var config = {
map: {
'*': {
myWidget: 'Magento_Theme/js/my-widget'
}
},
config: {
mixins: {
'Magento_Theme/js/my-widget': {
'Magento_Theme/js/my-widget-mixin': true
}
}
}
};
my-widget.js
define([
'jquery',
'jquery-ui-modules/widget'
], function ($) {
'use strict';
$.widget('mage.myWidget', {
options: {
color: 'red'
},
_create: function () {
$('body').css('background-color', this.options.color);
}
});
return $.mage.myWidget;
});
my-widget-mixin.js
define([
'jquery',
'jquery-ui-modules/widget'
], function ($) {
'use strict';
return function (widget) {
$.widget('mage.myWidget', widget, {
options: {
color: 'green'
}
});
return $.mage.myWidget;
}
});
Expected result (*)
Mixin load and background is GREEN 🟢
Actual result (*)
Results depend on cache, opened devtools.
- Init widget on js file – mixin don't load (or randomized loading, also loading when devtools opened)
Background is RED 🔴 or GREEN 🟢
define([
'jquery',
'myWidget'
], function ($, myWidget) {
'use strict';
myWidget();
});
- Init widget on phtml file – mixin don't load (or randomized loading, also loading when devtools opened)
Background is RED 🔴 or GREEN 🟢
require([
'jquery',
'myWidget'
], function ($, myWidget) {
'use strict';
myWidget();
});
- Init widget on js file (with mage) – mixin load (or randomized don't loading)
Background is GREEN 🟢 or RED 🔴
require([
'jquery',
'mage/mage'
], function ($) {
'use strict';
$('body').mage('myWidget', {});
});
- Init widget on js file (without alias) – mixin load (or randomized don't loading when devtools opened)
Background is GREEN 🟢 or RED 🔴
define([
'jquery',
'Magento_Theme/js/my-widget'
], function ($, myWidget) {
'use strict';
myWidget();
});
- ALSO, when widget don't load and when call widget again (click event, etc) – mixin load
Background is RED 🔴, after event is GREEN 🟢
require([
'jquery',
'myWidget'
], function ($, myWidget) {
'use strict';
myWidget();
$('.action.mixin').on('click', function () {
myWidget();
});
});
- Init widget on phtml file with
data-mage-init
– mixin load (works perfectly, without background flashing and mixin preloading)
Background is GREEN 🟢
<div data-mage-init='{"myWidget": {}}'></div>
- Init widget on phtml file with js
x-magento-init
– mixin load (works perfectly, without background flashing and mixin preloading)
Background is GREEN 🟢
<script type="text/x-magento-init">
{
"*": {
"myWidget": {}
}
}
</script>
- Init widget on js file (with mixins!) – mixin load (works perfectly, without background flashing and mixin preloading)
Background is GREEN 🟢
define([
'jquery',
'mixins!myWidget'
], function ($, myWidget) {
'use strict';
myWidget();
});
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmedA defect with this priority could have functionality issues which are not to expectations.The issue has been reproduced on latest 2.4-develop branchAffects critical data or functionality and forces users to employ a workaround.Issue related to Developer Experience and needs help with Triage to Confirm or Reject it