Make WordPress Core

Opened 9 years ago

Closed 5 years ago

#34181 closed defect (bug) (maybelater)

&nbsp; on a <td> disappearing when switching from Text to Visual tab

Reported by: inggo's profile Inggo Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3.1
Component: TinyMCE Keywords:
Focuses: Cc:


If I have this on the "Text" tab of TinyMCE:


And switch to the "Visual" tab, then switch back to "Text", the &nbsp; on the <td> disappears. Output becomes:


Change History (5)

#2 @SergeyBiryukov
9 years ago

  • Summary changed from &nbsp; on a <td> disappearing when switching from to &nbsp; on a <td> disappearing when switching from Text to Visual tab

This ticket was mentioned in Slack in #core-editor by iseulde. View the logs.

8 years ago

#4 @iseulde
8 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

Thanks for the report!

Seems to be related to autop in JS. Also creating a table in the text editor without spaces will get spaces when switching to the visual editor.

Needs tests.

#5 @azaozz
5 years ago

  • Resolution set to maybelater
  • Status changed from new to closed

Yes, this comes from the js autop. The &nbsp; is converted to U+00A0 by TinyMCE (it is set to do that), and U+00A0 is matched by \s in the autop regex.

The way this can be fixed is perhaps to look at "empty" <td>{U+00A0}</td> and replace the UTF-8 char with the entity after the TinyMCE cleanup but before autop. Potentially this may bring some edge cases on the front-end, in the PHP autop.

On the other hand this is superseded by the block editor. The Table block there works well and doesn't seem to have this problem, so not sure if it's worth it fixing for the classic editor.

Closing as maybelater. Feel free to reopen is this is still needed/has common use cases.

Note: See TracTickets for help on using tickets.