Comments Don't Support New Lines #274

Closed
opened 2025-09-16 21:07:20 +00:00 by numberss · 4 comments
Member

https://maps.strafes.net/mapfixes/80

You can see in my comment on this fix that I wrote the comment with new lines in mind in the comment box, but when posted it sent as one big paragraph instead of keeping the new lines i created

https://maps.strafes.net/mapfixes/80 You can see in my comment on this fix that I wrote the comment with new lines in mind in the comment box, but when posted it sent as one big paragraph instead of keeping the new lines i created
Owner

You can see that it's saved correctly into the database here: https://maps.strafes.net/api/mapfixes/80/audit-events?Page=1&Limit=100

So it's just being displayed incorrectly by whatever JavaScript powers that be. The exact line of code responsible for the comment text is right here:

<Typography variant="body2">{decodeAuditEvent(event)}</Typography>
The text comes from decodeAuditEvent(event). There is probably some sort of HTML attribute for Typography that makes it not be stupid. Maybe search for "Material UI Typography newlines" or something. A quick websearch yields the display attribute with a couple possible values to try being display="block" or display="inline", I have no idea where the specific documentation for that is though.

You can see that it's saved correctly into the database here: https://maps.strafes.net/api/mapfixes/80/audit-events?Page=1&Limit=100 So it's just being displayed incorrectly by whatever JavaScript powers that be. The exact line of code responsible for the comment text is right here: https://git.itzana.me/StrafesNET/maps-service/src/commit/456b62104bb2d2f8300fd35366da96e7cec699ee/web/src/app/_components/comments/CommentItem.tsx#L32 The text comes from `decodeAuditEvent(event)`. There is probably some sort of HTML attribute for Typography that makes it not be stupid. Maybe search for "Material UI Typography newlines" or something. A quick websearch yields the display attribute with a couple possible values to try being `display="block"` or `display="inline"`, I have no idea where the specific documentation for that is though.
Author
Member

After some searching apparents adding style={{whiteSpace: 'pre-line'}} inside the <Typography ... > allows \n to be rendered correctly. I have no clue how to test this in the website code so I am going to leave that to someone else to do (sorry).

See https://github.com/mui/material-ui/issues/9189

After some searching apparents adding `style={{whiteSpace: 'pre-line'}}` inside the `<Typography ... >` allows \n to be rendered correctly. I have no clue how to test this in the website code so I am going to leave that to someone else to do (sorry). See https://github.com/mui/material-ui/issues/9189
Owner

Follow the README.md instructions for the website and point it to the staging backend using a file named .env:

API_HOST=https://maps.staging.strafes.net/api/
AUTH_HOST=https://auth.staging.strafes.net/

After it's running (bun run dev) you should be able to use it in your browser at http://localhost:8080

I'm pretty sure it even supports hot reloading so you can make changes to the javascript code in real time

Follow the README.md instructions for the website and point it to the staging backend using a file named `.env`: ``` API_HOST=https://maps.staging.strafes.net/api/ AUTH_HOST=https://auth.staging.strafes.net/ ``` After it's running (`bun run dev`) you should be able to use it in your browser at http://localhost:8080 I'm pretty sure it even supports hot reloading so you can make changes to the javascript code in real time
Quaternions added the help wanted label 2025-09-24 04:53:22 +00:00
Owner
https://git.itzana.me/StrafesNET/maps-service/pulls/289
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: StrafesNET/maps-service#274