WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#31998 closed defect (bug) (fixed)

wp.mce.views with focus causes JS errors when toggling visual editor view

Reported by: Clorith Owned by: azaozz
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.2
Component: TinyMCE Keywords: has-patch commit
Focuses: javascript Cc:

Description

As reported by @maniu in https://wordpress.org/support/topic/wpmceviews-update-switching-visualtextvisual-causes-appendchild-js-error

When switching views between visual and text mode in the post editor the visual editor will fail to render upon toggle if a view was currently active/had focus when you moved away from the visual mode.

In previous versions we appear to move the focus in the editor to the first point before the view element when we change views.

Attachments (1)

31998.patch (863 bytes) - added by azaozz 4 years ago.

Download all attachments as: .zip

Change History (10)

#1 @SergeyBiryukov
4 years ago

  • Summary changed from wp.mce.views with focus causes JS errors when toggeling visual editor view to wp.mce.views with focus causes JS errors when toggling visual editor view

#2 @azaozz
4 years ago

  • Component changed from Editor to TinyMCE
  • Milestone changed from Awaiting Review to 4.2

Caused by trying to remove a view that doesn't exist any more as we reload the editor content (and recreate all views) on switching Text => Visual.

@azaozz
4 years ago

#3 @azaozz
4 years ago

In 31998.patch:

  • Remove selected views when inserting content but not when loading all content.
  • Remove the ref. to the selected view node on resetting the views.

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


4 years ago

#5 @iseulde
4 years ago

  • Keywords has-patch added

Patch works well here and solves the problem.

#6 @ocean90
4 years ago

  • Keywords commit added

Looks good.

#7 @azaozz
4 years ago

  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In 32140:

TinyMCE wpView:

  • Remove selected views when inserting content but not when loading all content.
  • Remove the ref. to the selected view node on resetting the views.

Fixes #31998.

#8 follow-up: @ianatkins
4 years ago

Did this make it into 4.2.2? I'm experiencing similar issues.

#9 in reply to: ↑ 8 @azaozz
4 years ago

Replying to ianatkins:

Of course: https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/js/tinymce/plugins/wpview/plugin.js#L186

If you're seeing similar problems, please open a new ticket with steps to reproduce.

Note: See TracTickets for help on using tickets.