Shopify has a very useful method in its Embedded App SDK
for showing errors on a small red floating modal : ShopifyApp.flashError("Your error");
My problem is that I cannot have multiline errors in it. I have tried n
, /n
, /r
, r
, <br />
and 
for having newline
. None worked! Any Ideas?
2
Answers
Looks like ShopifyApp.flashError makes a call to postMessage:
So, if you can find the bit of logic that is listening for messages sent to “Shopify.API.flash.error” you can find the code which renders the message. However, given the
r = JSON.stringify({ message: e, data: t})
call, I suspect you are out of luck insofar as passing in a special enough character to invoke a newline.No, there currently isn’t a way to do this. If you look at the Shopify page source code, you can find the template used to render alerts:
So your message is being put into a regular paragraph, without anything fancy like
white-space: pre-line
. And since text inserted into templates isn’t allowed to contain HTML tags, you cannot use a<br>
tag either.