Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#41475 closed defect (bug) (maybelater)

TinyMCE switches <strong> to <b> on deleted, then replaced text

Reported by: cainm's profile cainm Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: TinyMCE Keywords:
Focuses: Cc:

Description

Steps to reproduce

  1. Go to the visual editor or the new TinyMCE text widget.
  2. Write some text. Highlight it and use TinyMCE to make it bold.
  3. View Text mode - TinyMCE correctly used <strong> for bolding.
  4. Return to Visual mode, highlight bolded text, delete, then replace text.*
  5. View Text mode - TinyMCE switched <strong> to <b>.

*If you just replace the bolded text without deleting first, <strong> is still used.

Expected

The same tag (<strong>) should be used when deleting and replacing TinyMCE bolded text.

Actual

<strong> is correctly used for general replacing of TinyMCE bolded text, except when text is fully deleted before being replaced.

Browser / OS version

Chrome 59.0.3071.115 / macOS Sierra 10.12.6

Video

https://cloudup.com/i0I4EEt1TiG

Possibly related: #6026

Additional note: Similar issue in Gutenberg, although <span style="font-weight:600"> is used instead of <b>. Opening a separate issue in the Gutenberg repo.

Attachments (1)

41475.diff (873 bytes) - added by xkon 7 years ago.
Fixes <strong> to <b> and <em> to <i> after deleting text

Download all attachments as: .zip

Change History (7)

#1 @afercia
7 years ago

  • Keywords needs-patch added
  • Version changed from 4.8 to 4.3

Can reproduce in Chrome, Safari, Opera, and Edge.
Firefox and IE 11 keep the <strong>.
Can reproduce back to WP 4.3 (just because I haven't previous versions installed at the moment).

@xkon
7 years ago

Fixes <strong> to <b> and <em> to <i> after deleting text

#2 @xkon
7 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

Hello,

After seeing the code I found out that the <em> was getting replace by <i> in the same situation as <strong> so I've fixed that also in this 41475.diff given the oportunity.

Please make another test, I did on Chrome / Firefox / Edge without having issues.

Everything should remain as <strong> and <em> now.

Best regards,
Konstantinos

Last edited 7 years ago by xkon (previous) (diff)

#3 @azaozz
7 years ago

  • Keywords needs-patch added; has-patch removed

View Text mode - TinyMCE switched <strong> to <b>.

No, this is not TinyMCE's doing. Unfortunately this is the standard contenteditable behavior in some browsers.

By default TinyMCE inserts <strong> and <em> when the buttons are used and converts all <b> and <i> to <strong> and <em> on cleanup. We added the code that 41475.diff removes to stop that conversion when these tags are used explicitly, so the patch will effectively revert [27083], see #23037.

#4 @xkon
7 years ago

Oh, sorry for this. I didn't know it was intended due to past issues and now I understand why by viewing the mentioned tickets.

Thank you @azaozz .

Best regards,
Konstantinos

This ticket was mentioned in Slack in #core-tinymce by afraithe. View the logs.


7 years ago

#6 @azaozz
7 years ago

  • Keywords needs-testing needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

Not sure what we can do here. This seems to be a "feature" or rather a buggy feature in all WebKit browsers. I know TinyMCE has attempted to fix this but there may be some edge cases that will still convert <strong> or <b> to a span with inline style...

Closing as maybelater for now as most cases will be fixed with the next TinyMCE update. For a complete fix this will have to be fixed in the affected browsers, but don't hold your breath, this bug has been around for many years :)

Note: See TracTickets for help on using tickets.