Bug 16301 - Gmail: Canceling an Edit Link dialog applies a link to the first line of selected text
Summary: Gmail: Canceling an Edit Link dialog applies a link to the first line of sele...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Evangelism (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords: GoogleBug, HasReduction, InRadar
Depends on:
Blocks:
 
Reported: 2007-12-04 20:19 PST by Justin Garcia
Modified: 2008-05-20 17:18 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Justin Garcia 2007-12-04 20:19:23 PST
In GMail, when I create two paragraphs of text, select them, click Edit Link, and then cancel the Edit Link dialogue, the first paragraph is made into a link.

When the Edit Link dialogue appears, GMail creates a link from the selection with document.execCommand("CreateLink", ...), and then when I cancel the dialogue, GMaill tries to remove the link by removing the last anchor in the selection.  This won't always unlink the entire selection because we sometimes create multiple anchor elements during CreateLink to preserve the structure of the selection.  For example imagine selecting 'foo' and 'bar' below:

foo<ul><li>bar</li><li>baz</li></ul>

and performing CreateLink.  WebKit will create two anchor elements since there is no way to insert only one that contains the entire selection but does not require splitting the list.

You could fix this issue by calling document.execCommand("Unlink") on the selection if the user cancels out of the Edit Link dialogue.

<rdar://problem/5616266> Gmail: Clicking Cancel in Edit Link dialog applies a link to the first line of selected text
Comment 1 Justin Garcia 2008-05-20 17:18:23 PDT
This looks fixed.