Enter key in nested list creates item at same level in Chrome
OS: Windows 11 · Device: Desktop or Laptop Any · Browser: Chrome 120.0 · Keyboard: US
Open case →Scenario
When editing nested lists (lists within list items), the behavior of Enter, Backspace, Delete, and Tab keys varies significantly across browsers. Creating, editing, and deleting nested list items can result in unexpected DOM structures or lost formatting.
When editing nested lists (lists within list items), the behavior of Enter, Backspace, Delete, and Tab keys varies significantly across browsers. Creating, editing, and deleting nested list items can result in unexpected DOM structures or lost formatting.
Implement custom handling for nested list operations:
element.addEventListener('beforeinput', (e) => {
if (e.inputType === 'insertParagraph') {
const selection = window.getSelection();
if (selection.rangeCount === 0) return;
const range = selection.getRangeAt(0);
const listItem = range.startContainer.closest('li');
if (listItem) {
// Check if we're in a nested list
const parentList = listItem.closest('ul, ol');
const parentListItem = parentList?.parentElement;
if (parentListItem?.tagName === 'LI') {
e.preventDefault();
// Implement custom nested list item creation
handleNestedListItemInsertion(listItem, range);
}
}
}
// Handle Tab for indentation
if (e.inputType === 'insertText' && e.data === '\t') {
const selection = window.getSelection();
if (selection.rangeCount === 0) return;
const range = selection.getRangeAt(0);
const listItem = range.startContainer.closest('li');
if (listItem) {
e.preventDefault();
// Implement custom indentation logic
handleListIndentation(listItem);
}
}
});
Visual view of how this scenario connects to its concrete cases and environments. Nodes can be dragged and clicked.
Each row is a concrete case for this scenario, with a dedicated document and playground.
| Case | OS | Device | Browser | Keyboard | Status |
|---|---|---|---|---|---|
| ce-0099-nested-list-enter-chrome | Windows 11 | Desktop or Laptop Any | Chrome 120.0 | US | draft |
| ce-0134-nested-list-tab-indent | Windows 11 | Desktop or Laptop Any | Chrome 120.0 | US | draft |
| ce-0143-nested-list-backspace | Windows 11 | Desktop or Laptop Any | Firefox 120.0 | US | draft |
This matrix shows which browser and OS combinations have documented cases for this scenario. Click on a cell to view the specific case.
| Browser | Windows |
|---|---|
| Chrome | |
| Firefox |
Open a case to see the detailed description and its dedicated playground.
OS: Windows 11 · Device: Desktop or Laptop Any · Browser: Chrome 120.0 · Keyboard: US
Open case →OS: Windows 11 · Device: Desktop or Laptop Any · Browser: Chrome 120.0 · Keyboard: US
Open case →OS: Windows 11 · Device: Desktop or Laptop Any · Browser: Firefox 120.0 · Keyboard: US
Open case →Other scenarios that share similar tags or category.
Editing text within blockquote elements in contenteditable behaves inconsistently across browsers. Pressing Enter, applying formatting, or pasting content may break the blockquote structure, create nested blockquotes, or behave unexpectedly.
The behavior of Enter and Shift+Enter keys in contenteditable elements varies across browsers. Enter may create a new paragraph, line break, or div, while Shift+Enter may create a line break or behave differently. The resulting DOM structure also varies.
When editing text within list items, formatting such as bold, italic, or links may be lost or behave unexpectedly. The list structure itself may also be lost when certain operations are performed, such as pasting content or applying formatting.
When pressing Backspace or Delete at the beginning or end of a list item, the behavior varies significantly across browsers. Some browsers delete the list item and merge with adjacent content, while others may delete the entire list or create unexpected DOM structures.
Applying multiple formatting operations (bold, italic, underline, etc.) creates nested HTML elements that can become complex and hard to manage. Browsers handle nested formatting differently, and the resulting DOM structure can be inconsistent.
Have questions, suggestions, or want to share your experience? Join the discussion below.