parse-dashboard icon indicating copy to clipboard operation
parse-dashboard copied to clipboard

Line breaks are lost when displaying text in info panel

Open 404-html opened this issue 10 months ago • 4 comments

New Issue Checklist

Issue Description

When showing a multi line text in info panel, the line breaks are lost, and text is rendered as a single line.

Image

Steps to reproduce

Setup info panel on a collection, and return following from the cloud function:

{
  panel: {
    segments: [
      {
        title: "User Info",
        items: [
          {
            type: "text",
            text: `
line 1

line 2`,
          },
        ],
      },
    ],
  },
}

Actual Outcome

Besides the line breaks, text is wrapped into single line.

Expected Outcome

I would expect line breaks to be preserved.

Environment

Dashboard

  • Parse Dashboard version: 6.0.0-alpha.28
  • Browser (Safari, Chrome, Firefox, Edge, etc.): Chrome
  • Browser version: 131.0.6778.205 (Official Build) (arm64)

Server

  • Parse Server version: any
  • Operating system: any
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): local

Database

  • System (MongoDB or Postgres): any
  • Database version: any
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): any

Logs

404-html avatar Feb 02 '25 21:02 404-html

Thanks for opening this issue!

  • 🚀 You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

You mean to convert \n to <br />? Did you try to do that conversion on your data side? It may get escaped, but worth a try.

mtrezza avatar Feb 02 '25 21:02 mtrezza

You mean to convert \n to <br />? Did you try to do that conversion on your data side? It may get escaped, but worth a try.

Yes, I tried both (adding into text on the cloud function side) - no effect. Here's what worked:

<p style="white-space: pre-line;">...</p>

404-html avatar Feb 02 '25 21:02 404-html

What would be a solution to this? On one hand the data should be escaped to not put the burden on the developer. On the other hand how should they enter a line-break? I suggest to add an option the text item where the text is not escaped at all and just displayed as is. That would even allow for style tags<b> or lists <ul>. Could be risky though, if the data displayed is data from a user and that data includes malicious code. But we could add a warning label to that option.

mtrezza avatar Feb 02 '25 21:02 mtrezza