Phenomenon
When pressing Backspace at the beginning of a list item in Firefox, the entire list may be deleted or unexpected nested structures may be created. This behavior differs from Chrome, which converts the list item to a paragraph.
Reproduction example
- Create a list with items:
<ul><li>Item 1</li><li>Item 2</li></ul> - Place cursor at the very beginning of the first list item
- Press Backspace
Observed behavior
- The entire list may be deleted
- Or nested list structures may be created unexpectedly
- List items may be converted to paragraphs in an inconsistent way
- DOM structure may become malformed
Expected behavior
- The list item should be deleted while maintaining list structure
- Remaining list items should stay in the list
- Behavior should be consistent with Chrome
Browser Comparison
- Chrome/Edge: Converts list item to paragraph (more predictable)
- Firefox: May delete entire list (this case)
- Safari: May create empty list items
Notes and possible direction for workarounds
- Intercept
beforeinputevents to prevent default behavior - Implement custom deletion that maintains list structure
- Check for list context before allowing deletion
- Normalize DOM structure after deletion operations