Streaming Markdown in Safari sometimes results in broken list items #1262
-
Please see the above video, which illustrates the problem. I constantly set the array of messages in the conversation which triggers rerendering and the last message has incomplete markup. Depending on how exactly it was broken up, I end up with these list items that have a weird vertical offset in the text. Not sure if it only happens with these Any hints what I could do? Is it perhaps a bug in your plugin? Or maybe in Safari? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Welcome @stippi2! Sorry you ran into a spot of trouble.
Some things to look into:
|
Beta Was this translation helpful? Give feedback.
-
Thank you very much for providing your input! I have tried to get a minimal reproducable test-case. In this branch of my project, I have simulated the updates to the markdown content. I have recorded the progression of the content, and assembled a sequence that can be used to reproduce the issue. I've narrowed it down to just two consecutive states: [
{
"role": "user",
"content": "Can you give me a list of 5 good science fiction movies?"
},
{
"role": "assistant",
"content": "Certainly! Here are five highly-regarded science fiction movies that you might enjoy:\n\n1. \"Blade Runner\" (1982) – Directed by Ridley Scott and starring Harrison Ford, this film is a visually stunning exploration of artificial intelligence and identity.\n\n2"
}
] -> [
{
"role": "user",
"content": "Can you give me a list of 5 good science fiction movies?"
},
{
"role": "assistant",
"content": "Certainly! Here are five highly-regarded science fiction movies that you might enjoy:\n\n1. \"Blade Runner\" (1982) – Directed by Ridley Scott and starring Harrison Ford, this film is a visually stunning exploration of artificial intelligence and identity.\n\n2. \"The Matrix\" (1999) – Directed by the Wachowski siblings, this movie revolutionized special effects with its groundbreaking \"bullet time\" sequences and presents a compelling cyberpunk story.\n\n3. \"Inception\" (2010) – Directed by Christopher Nolan, this mind-bending thriller delves into the world of dreams and features a complex narrative structure.\n\n"
}
] So in the first pass, the markdown ends on the next number of the list block. This is what triggers the Safari rendering issue. If rendering directly the final resulting state, there is no problem. But switching from the first to the second state triggers it. If you want to try for yourself, I hope it is easy to do so with my project. For the API keys, you could just add dummy values (see the README.md for what I mean.) The updates are triggered via this effect. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the pointers and sorry for the late reply. This is my fork of the starter sandbox on Codesandbox. Open in Safari 17.2.1 (19617.1.17.11.12) on macOS to see the problem. |
Beta Was this translation helpful? Give feedback.
-
Hi, @stippi2 |
Beta Was this translation helpful? Give feedback.
Thanks @stippi2!
There is no issue, with
react-markdown
the HTML output is correct in Safari.The issue is with styles. Safari has different default styles, and potentially a bug in how Safari handles block layout inside lists.
Consider adding a stylesheet with
to reduce layout differences between browsers.