Support

Account

Home Forums General Issues Unwanted &nbsp in text field – how to get rid of?

Solving

Unwanted &nbsp in text field – how to get rid of?

  • This may or may not be an ACF issue, but I have a normal ACF text field, and for some reason it’s inserting a   between the last and second to last word. This is causing issues in that the last 2 words are then not breaking onto a new line and spilling out of the surrounding div.

    I have tried deleting the text and writing it out manually just to rule out any copy/paste issues and still getting the same.

    I’m tearing my hair out over this issue, any advice would be welcome!

  • ACF will not add this character to the text.

    However, if you hold the shift key when you are typing the space this will insert a   into the text editor. Is it possible that this is happening?

    If this is not the case then there would have to be some filter on your site that is doing this on an ACF hook like acf/save_post or acf/update_field or even acf/format_value. Have you looked in the DB to see if the character is in the saved content of the field?

  • I’m having the same issue.

    In my case this is only happening with nested repeaters/groups, specifically:

    – Repeater
    – Group
    – Repeater
    – Text [has whitespace issues]

    In other cases with the same setup, this isn’t happening, e.g,:

    – Repeater
    – Text [no issues here]

    Any updates on this? I have tried for several days now, did lots of research, double-checked the source, looked for copy & paste errors, tried to sanitize this in every way you could possibly think of, but nothing can seem to fix it.

    First of all, the #Text nodes aren’t being wrapped inside their parent element correctly, which I’ve seen before, and which might even be common. I was able to fix that, however, there are still spaces around the actual text–a regular leading whitespace and a non-breaking trailing whitespace.

    Example:

    <a href=""> Hello There </a>

    Before the fix it was actually not even wrapped and looked like this:

    <a href=""></a>
               Hello There          

    I’m fairly certain everything is set up correctly and that the source material is clean too. Also, everything is working fine elsewhere. This is only happening when repeaters/groups are nested (twice?). Is there something that I am missing? Are there any known solution to this?

    Thanks much.

  • Before you ask, just to name a few of the things I’ve tried:

    Trimmed any whitespace from fields before output.

    Replaced non-breaking with regular spaces.

    Collapsed multiple spaces into a single space.

    Removed control or invisible characters like zero-width spaces.

    Cleared extra spaces between tags using regex.

    But the issue remains and the root cause seems to be lying deeper within ACF. I also don’t think all these steps should be necessary in order to output clean text.

  • Of course this is what the structure looks like:

    => Repeater
    ==> Group
    ===> Repeater
    ====> Text [has whitespace issues]

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.