Skip to content

fix: Preserve line breaks in info panel text item#3379

Closed
dblythy wants to merge 2 commits into
parse-community:alphafrom
dblythy:fix/2651-info-panel-line-breaks
Closed

fix: Preserve line breaks in info panel text item#3379
dblythy wants to merge 2 commits into
parse-community:alphafrom
dblythy:fix/2651-info-panel-line-breaks

Conversation

@dblythy

@dblythy dblythy commented Jul 4, 2026

Copy link
Copy Markdown
Member

Closes #2651

Info panel text items lost line breaks: newlines (\n) in the value collapsed into spaces because the text was rendered in a plain <p> (default white-space: normal). Setting white-space: pre-line preserves author-entered line breaks while still collapsing redundant spaces. The text remains an escaped React child (no dangerouslySetInnerHTML), so there is no XSS risk.

Before

before

After

after

Summary by CodeRabbit

  • Bug Fixes
    • Improved text display so line breaks in paragraph content are preserved as expected.

@parse-github-assistant

Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title fix: preserve line breaks in info panel text item fix: Preserve line breaks in info panel text item Jul 4, 2026
@parse-github-assistant

Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4f858f6-4df0-439c-8991-2871f5d3a019

📥 Commits

Reviewing files that changed from the base of the PR and between 9db24be and 3f3db23.

📒 Files selected for processing (1)
  • src/components/AggregationPanel/AggregationPanelComponents.js

📝 Walkthrough

Walkthrough

A single-line CSS change was applied to the TextElement component's paragraph rendering, adding an inline whiteSpace: 'pre-line' style to preserve newline formatting in displayed text.

Changes

Text formatting fix

Layer / File(s) Summary
Apply pre-line whitespace style to TextElement
src/components/AggregationPanel/AggregationPanelComponents.js
The <p> element rendering text now includes an inline style with whiteSpace: 'pre-line' to preserve line breaks, replacing the previous unstyled paragraph.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Related issues: Fixes line breaks being lost when displaying multi-line text in the info panel (#2651).

Suggested labels: bug, ready-to-merge

Suggested reviewers: mtrezza

🐰 A rabbit hops through lines of code,
Where breaks were lost, now newly flowed.
One style applied, so simple and neat,
Multi-line text now reads complete.

🚥 Pre-merge checks | ✅ 5 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the issue and approach, but it does not follow the required template headings or task checklist. Add the Issue, Approach, and Tasks sections from the template, and include the checklist items or note why they do not apply.
Engage In Review Feedback ❓ Inconclusive The line-break fix is present, but the repo doesn’t contain review-thread evidence to prove feedback was discussed before resolution. Provide PR review comments or GitHub discussion history showing the feedback was addressed after engagement, or this check can’t be verified.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the change and uses the required fix: prefix.
Linked Issues check ✅ Passed The patch preserves line breaks in info panel text with pre-line, which matches the goal in #2651.
Out of Scope Changes check ✅ Passed The PR only changes the targeted text rendering behavior and introduces no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Security Check ✅ Passed Style-only change to preserve newlines; text stays as escaped React children and no new risky patterns like innerHTML or URL handling were introduced.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@dblythy dblythy requested a review from mtrezza July 4, 2026 14:50

@mtrezza mtrezza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No images, CR hit limit, branch not up-to-date. req again when all done

@dblythy

dblythy commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

@mtrezza images restored

@mtrezza

mtrezza commented Jul 4, 2026

Copy link
Copy Markdown
Member

What's the source of text that now shows line breaks? What's causing these breaks?

@dblythy

dblythy commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

This here is the response of a cloud function, if you returned hello\nworld for example

@mtrezza

mtrezza commented Jul 4, 2026

Copy link
Copy Markdown
Member

Condensing text in a side panel is a feature I'd argue, not a bug. There is limited space in a side panel. It currently condenses line breaks, tabs, spaces. Respecting just line breaks seems arbitrary to me. And what if someone requests to respect tabs and spaces tomorrow? I believe by default it should collapse (status quo) because information density is key. Formatting should be deterministic in code - it's HTML after all. I'd rather lean towards allowing HTML tags, which gives a dev more freedom, including <ul>, etc. See #2651 (comment).

Btw, doesn't the text element already support a style property? A segment does, so a dev could probably set white-space: pre-line already? Does this issue even require a PR?

@dblythy

dblythy commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

Respecting newlines isn't really arbitrary - \n is a hard line break in Unicode (UAX #14), not a CSS thing, whereas a space isn't. iOS, Android and web all treat \n as a break already, so honouring it just follows the text standard. pre-line is only how the web opts back in after CSS collapses everything.

That said, you're right that a dev can already pass style through as a workaround today:

{ type: 'text', text: '...', style: { whiteSpace: 'pre-line' } }

i think it'd stump most dashboard devs to have to reach for CSS just to keep a line break they explicitly typed.

On raw HTML, IMV i'd steer clear. The text often interpolates user data (Bio: ${user.get('bio')}), so it's an XSS vector straight into the dashboard, which holds the masterKey. If we want formatting, sanitised markdown feels safer but a bigger scope.

Don't feel strongly though - happy for you to close this and the issue if you're good with the workaround.

@mtrezza

mtrezza commented Jul 4, 2026

Copy link
Copy Markdown
Member

Respecting newlines isn't really arbitrary - \n is a hard line break in Unicode

I don't understand the argument - tabs are also a unicode char. It is arbitrary in the sense that the default is to condense text. Why do you want to single out line breaks but keep condensing tabs and spaces?

i think it'd stump most dashboard devs to have to reach for CSS just to keep a line break they explicitly typed.

I would be very surprised - that should never be an expectation in HTML. Not only is it not the default behavior, condensing text is also the historic normal, long before CSS. white-space is a fairly young property. The expectation of a dev should be condensing, unless explicitly setting the CSS property.

@dblythy dblythy closed this Jul 5, 2026
@dblythy dblythy deleted the fix/2651-info-panel-line-breaks branch July 5, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Line breaks are lost when displaying text in info panel

2 participants