Bug 24362 - Cannot backspace out of list at start of contentEditable region
: Cannot backspace out of list at start of contentEditable region
Status: NEW
: WebKit
HTML Editing
: 528+ (Nightly build)
: PC Mac OS X 10.5
: P2 Normal
Assigned To:
: http://www.mozilla.org/editor/midasdemo/
:
: 35281
:
  Show dependency treegraph
 
Reported: 2009-03-04 10:48 PST by
Modified: 2013-03-15 07:22 PST (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2009-03-04 10:48:32 PST
Steps to reproduce:

1. Go to Midas Demo: http://www.mozilla.org/editor/midasdemo/
2. Check "View HTML Source" and type the following HTML:
<ul><li>a</li></ul>
3. Uncheck "View HTML Source" and put the cursor before the 'a' character.
4. Press backspace.

Actual result:
Nothing happens

Expected result:
List item deleted.

This affects Google Docs. Possibly related to bug 11331?
------- Comment #1 From 2009-03-06 11:48:33 PST -------
There seems to be code to specifically enable this:

void TypingCommand::deleteKeyPressed(TextGranularity granularity, bool killRing)


            // When the caret is at the start of the editable area in an empty list item, break out of the list item.
            if (endingSelection().visibleStart().previous(true).isNull()) {
                if (breakOutOfEmptyListItem()) {
                    typingAddedToOpenCommand();
                    return;
                }
            }

Obviously that code is not working. :)

Will investigate.
------- Comment #2 From 2009-03-06 12:29:13 PST -------
Oh, that code is working fine.  This bug is asking to be able to remove the list item even when the list item isn't empty. :)
------- Comment #3 From 2009-08-14 18:15:46 PST -------
(In reply to comment #2)
> Oh, that code is working fine.  This bug is asking to be able to remove the
> list item even when the list item isn't empty. :)

Firefox and TextEdit on Mac removes the bullet (i.e. unlistify the text).  I think we should fix this behavior.
------- Comment #4 From 2010-02-21 21:32:01 PST -------
(In reply to comment #3)
> (In reply to comment #2)
> > Oh, that code is working fine.  This bug is asking to be able to remove the
> > list item even when the list item isn't empty. :)
> 
> Firefox and TextEdit on Mac removes the bullet (i.e. unlistify the text).  I
> think we should fix this behavior.

To clarify: Firefox only removes the bullet if it's the first item in the list.  Otherwise, it merges with the previous list item.

I will investigate.
------- Comment #5 From 2010-02-22 19:42:36 PST -------
Ok, I think we want to go with IE's and TextEdit's behavior here.  If the cursor is at the beginning of a list item, it unindents it.  Once unindented, pressing backspace a second time merges the text with the previous item.

Before I can fix the list behavior, I need to fix bug 35281 (otherwise, the second backspace would result in two separate lists).
------- Comment #6 From 2011-08-18 13:30:46 PST -------
The behavior I specced is roughly

* If at the beginning of the first <li> in the list, unindent the <li>, leaving it on a separate line from whatever is before it.  Then a second backspace merges it into the previous block.
* If at the beginning of an <li> that's not the first in the list, merge with the previous <li>, keeping the contents on separate lines (add <br> if necessary).  Then a second backspace merges it to the same line as the previous item.

http://aryeh.name/spec/editing/editing.html#the-delete-command

According to my notes, this behavior doesn't match any browser, but I felt it made more sense than what any browser did.
------- Comment #7 From 2013-03-15 07:22:53 PST -------
Can I submit a patch for this bug without waiting for bug 35281?  The fix for this seems much simpler.

The fact that the second backspace doesn't merge the lists is an issue that only happens if there is a previous list item, and that isn't the case here.

This bug is specifically to do with being at the start of a contentEditable region, (and I would extend it to include start of table-cells), so by definition there is no previous list item.  So I don't think it should be blocked by bug 35281.