Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#38229 closed defect (bug) (wontfix)

Open link in new tab stays checked when creating new links.

Reported by: joelstransky's profile JoelStransky Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.6.1
Component: TinyMCE Keywords:
Focuses: Cc:


If while creating a link in TinyMCE you check the "Open link in new tab" and save, creating an additional new link will have the box ticked by default.

This appears be an oversite in wplink.js where


which is only called for brand new links, doesn't attempt to clear this box.

Suggested fix:
inputs.openInNewTab.prop( 'checked', false );

Change History (2)

#1 @adamsilverstein
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Hi @JoelStransky - thanks for the bug report and the screen capture which clearly illustrates the issue.

I agree that it would seem to make sense to reset the default values each time the link dialog is opened, and as you point out currently the setting persists until a browser refresh (even if you don't insert a link). My concern is that users are probably used to and now expecting the current sticky setting behavior which has been in place since at least WordPress 3.6. Because this is now expected behavior I'm going to close as won't fix, and offer you a solution to adjust this for your own use via a theme or plugin...

At the end of the open function in wpLink.js, we trigger an event on document: $( document ).trigger( 'wplink-open', inputs.wrap ); You should be able to adjust the default behavior here by hooking in with a listener in a plugin or theme.

Add this JS to wp admin pages (on admin_head for example):

jQuery( document ).on( 'wplink-open', function( e, wrap ) {
	jQuery( wrap ).find( '#wp-link-target' ).attr( 'checked', false );
} );

I tested in my local by dropping this code into the console on the editor page and the checkbox is not unchecked for each open:

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

7 years ago

Note: See TracTickets for help on using tickets.