0

As per default Magento 2 behavior, any message like success, error or notice, etc hide after 5 seconds. I don't want to hide any message so that user can read message.

See below image that display error message but hide after 5 seconds. enter image description here

I have override below files but not affect at all.

ROOT_FOLDER/vendor/magento/module-ui/view/frontend/web/js/view/messages.js

ROOT_FOLDER/vendor/magento/module-theme/view/frontend/web/js/view/messages.js

I have put above two files in my theme like below.

ROOT_FOLDER/app/design/frontend/Abc/xyz/Magento_Ui/web/js/view/messages.js

ROOT_FOLDER/app/design/frontend/Abc/xyz/Magento_Theme/web/js/view/messages.js

But not working. Please help me how to unhide M2 messages.

  • Have you try my answer? – Chirag Patel May 24 at 13:39
  • Is the issue resolved? – aravind May 27 at 12:43
  • No issue not resolved yet. Chirag patel you have answered for checkout page error and I am looking for general messages. – Hiren Shah May 27 at 13:01
  • @HirenShah I give the answer for checkout because in your question I have to see an image of the checkout page. And it is doesn't matter because in all Magento logic is the same for hiding message. – Chirag Patel Jun 11 at 8:53
  • And in your question, you have mentioned unhide Any message – Chirag Patel Jun 11 at 8:59
1

Overide the file

vendor/magento/module-ui/view/frontend/web/js/view/messages.js

TO

app/design/frontend/YourPackage/YourTheme/Magento_Ui/web/js/view/messages.js

Comment Out the below code,

onHiddenChange: function (isHidden) {
var self = this;
    // Hide message block if needed
    if (isHidden) {
       setTimeout(function () {
              $(self.selector).hide('blind', {}, 500);
       }, 5000);
}

Finally execute upgrade,Content commands

  • Hello arvind, How to override respected js file? – Hiren Shah May 27 at 10:18
  • You just need to place the file in following location mentioned above. And comment out that if condition ..I have updated my answer check now – aravind May 27 at 11:53
0

Actually, Magento removes error message after a few time using data-bind="visible: isVisible() this visible function call timer and hide message after some time so just remove this code it will work.

Do not remove data-bind="click otherwise user cannot remove message.

Try to below way :

Copy file from core Magento below-given path:

vendor/magento/module-ui/view/frontend/web/template/messages.html

Past in below path

app/design/frontend/YourPackage/YourTheme/Magento_Ui/web/template/messages.html

Replace below code

div data-role="checkout-messages" class="messages" data-bind="visible: isVisible(), click: removeAll">

With this code

<div data-role="checkout-messages" class="messages" data-bind="click: removeAll">

Run below command

bin/magento setup:upgrade

bin/magento setup:static-content:deploy

I hope it helps! Thanks.

  • Hello Chirag Patel. Thanks for the update but this is not working. Still message hide after 5 deconds. – Hiren Shah May 27 at 9:37
  • Remove var/* & generated/* folder and S:S:D -f and check. – Chirag Patel May 27 at 9:46
  • Chirag Patel How to un-hide global message which display on top of page? – Hiren Shah May 27 at 10:16

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.