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.

5
  • Have you try my answer? Commented May 24, 2019 at 13:39
  • Is the issue resolved?
    – aravind
    Commented May 27, 2019 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
    Commented May 27, 2019 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. Commented Jun 11, 2019 at 8:53
  • And in your question, you have mentioned unhide Any message Commented Jun 11, 2019 at 8:59

2 Answers 2

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

2
  • Hello arvind, How to override respected js file?
    – Hiren Shah
    Commented May 27, 2019 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
    Commented May 27, 2019 at 11:53
1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.