Opened 17 months ago

Closed 13 months ago

Last modified 13 months ago

#19528 closed defect (bug) (fixed)

HTML editor link quicktag not working in IE9

Reported by: JohnP Owned by: azaozz
Priority: high Milestone: 3.4
Component: Editor Version: 3.2
Severity: major Keywords: has-patch dev-feedback
Cc: curtiss@…

Description

Using IE9, type some text in the HTML editor, select a couple of words at the end and click "link" quicktag.

The Insert/edit link box pops up normally, enter URL, click "Add Link".

When you return to the editor, ALL the text is selected, and the link is placed at the beginning.

Can be fixed by setting browser to "compatibility view"

Not fixed by 3.3 upgrade.

Attachments (1)

19528.diff (1.2 KB) - added by solarissmoke 15 months ago.
Store selection information before textarea loses focus

Download all attachments as: .zip

Change History (7)

  • Keywords needs-patch added
  • Summary changed from HTML editor link quiktag not working in IE9 to HTML editor link quicktag not working in IE9
  • Version changed from 3.3 to 3.2

Introduced in WP 3.2.

Store selection information before textarea loses focus

  • Keywords has-patch dev-feedback added; needs-patch removed

Tracked this down to the following code in wplink.dev.js:

if ( typeof textarea.selectionStart !== 'undefined' ) {
	start       = textarea.selectionStart;
	end         = textarea.selectionEnd;
	selection   = textarea.value.substring( start, end );

This was originally designed to bypass IE which didn't support selectionStart/selectionEnd. However IE9 does. Problem is it sets both attributes to 0 when the textarea loses focus, which is what causes the behaviour described above.

Attached a patch that fixes this by storing the selection information before the textarea loses focus. This seems to me a better approach generally, as from what I can see the HTML5 spec doesn't explicitly say what should happen to selection data when focus is lost, so IE9 is not necessarily wrong in how it handles it.

  • Cc curtiss@… added
  • Milestone changed from Awaiting Review to 3.4
  • Priority changed from normal to high
  • Owner set to azaozz
  • Resolution set to fixed
  • Status changed from new to closed

In [20428]:

Fix inserting links in the HTML editor in IE9, fixes #19528

19528.diff would work too but better to use the native IE range object when in IE.

Note: See TracTickets for help on using tickets.