-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linebreaks are lost in comments #4741
Comments
Raised by moderators based on reader feedback |
It looks to me like there might be two separate issues here. 1. Styling on preview commentsThe markup for the comment contents appears to be the same for both the preview and server-rendered comments. Newlines in the comment input are being translated into a combination of css-kli0yq-Comment p {
margin-top: 0px;
margin-bottom: 12px;
} This style is missing from the preview wrapper (the wrapper for the preview is in fact a 2. Markup on client-rendered commentsThe client-rendered version of a submitted comment (i.e. what appears after submission, but before refreshing the page, seems to just be a plaintext version of the comment contents, with newlines preserved as newlines, hence not rendered as line breaks by the browser. ScreenshotsPreview<p class="css-12jyz7u"><p>hello world<br>linebreak</p> <p>another line break</p></p> Client-rendered (after submission)<div class="css-kli0yq-Comment">Hello world!
this is a line break
this is two
this is three</div> Server-rendered (after submission)<div class="css-kli0yq-Comment"><p>Hello world!<br>this is a line break</p> <p>this is two</p> <p><br>this is three</p></div> |
Update Preview rendering@mxdvl and I think we've resolved the first issue identified above, by adjusting the styling on DCR. Optimistic post-submission renderingIssue 2 from above (formatting for the 'optimistic client-side rendering of submitted comments) requires us to get the appropriate markup for the comment. Two possible options:
For reference, I think that the relevant parts of that codebase are: Creating the markup for the preview endpoint: Generating the response for the new comment endpoint: (I might be totally off here though, as this is my first time looking at that codebase.) |
Update on issue 2For the optimistic rendering, it looks as though this is done here: https://github.com/guardian/discussion-rendering/blob/78b97d5ad27f1579a9144edcd8f144a0a3591a3c/src/components/CommentForm/CommentForm.tsx#L325-L334 The value of Questions:
@oliverlloyd do you have any thoughts on this? |
Really great write up and investigation @bryophyta , thanks!
I think this is the best, most semantic, option. It is an additional change to a different codebase but you can take the rose tinted shiny happy view that downloading and learning a new codebase is a positive thing? Adding an extra api call on the client is a worse reader experience and is going to add complexity to the code.
Is this possible without changing the
At this point it is just DCR consuming |
Okay that's really helpful to hear, thanks! I agree that changing the API response would be nicest in many respects. My hesitation was partly due to not knowing how long it will take to make the edit, and also not knowing whether it could constitute a breaking change for any other consumers of the API. But from your comments it sounds like it might be worth spending the time to work these things out. Do you happen to have a sense of how we could find out whether adding a field to the |
Usually, adding more information isn't a breaking change. As long as the old keys are still present, there should be no problem with consumers. |
This probably shouldn't have been closed, as part of the issue is still unsolved. The solution outlined above to the second part of the issue looks viable, but it requires work on the discussion API. Currently this ticket is in the backlog. |
We are deprioritising this ticket by 'closing a not planned' - this won't delete the ticket and it will be searchable if the issue crops up again. Unfortunately we have over 130 health tickets to address in the web team and we can't address them all. With so many tickets we are potentially missing things that are high-impact so we're reorganising. |
We’ll be revisiting the broken preview as part of the discussion work in #10023 |
When previewing a comment or viewing it after it has been optimistically rendered additional line breaks are not shown. These missing breaks do appear when the page is refreshed and the server sent content is rendered.
The text was updated successfully, but these errors were encountered: