Skip to content
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

Duplicate <p> rendering on article pages #194

Closed
n30w opened this issue Nov 27, 2024 · 1 comment · Fixed by #195
Closed

Duplicate <p> rendering on article pages #194

n30w opened this issue Nov 27, 2024 · 1 comment · Fixed by #195
Assignees
Labels
bug Something isn't working
Milestone

Comments

@n30w
Copy link
Member

n30w commented Nov 27, 2024

Description

Articles currently have duplicated <p> rendering in the body when there is a whitespace in the portable text payload. This <p> contains no text. This should be removed.

Platform & operating system

MacOS Sequoia 15.1.1 - M1

What browsers are you seeing the problem on?

Firefox, Microsoft Edge

Steps to reproduce

  1. Navigate to any of our articles.
  2. Inspect element.

Additional context

image image
@n30w n30w added the bug Something isn't working label Nov 27, 2024
@n30w n30w added this to the v1.0 milestone Nov 27, 2024
@n30w
Copy link
Member Author

n30w commented Nov 27, 2024

Here's what I did to solve this:

  1. To reduce the variables and whether or not this was a library issue (we are using a local library of @portabletext/svelte, I used the @portabletext/svelte library but with an alpha version in a PR. See: Start support for Svelte 5 portabletext/svelte-portabletext#78 (comment). This didn't fix the issue.
  2. I stumbled upon this GitHub thread discussing blank spaces appearing in the HTML tree when using Sanity portable text. The thread is discussing a react component, however its easily applicable to Svelte. See: Empty lines coreyward/react-portable-text#18 (comment)
  3. I transformed the react code into Svelte code by observing the content returned by an article query and accessing the appropriate object and its values. There was already a hint in the component ArticleSingleComponentBlock.svelte, where it states:
let { value } = $derived(portableText);
let { style = 'normal' } = $derived(value);

There was also a value field in the object returned by the Sanity query.

  1. That's it!

@n30w n30w linked a pull request Nov 28, 2024 that will close this issue
4 tasks
@n30w n30w closed this as completed in #195 Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants