Skip to content

Richtext does not allow nesting unordered and ordered lists #11178

@frlruehle

Description

@frlruehle

What you were expecting:
Nesting an ordered list within a bullet list by indenting and then switching the list type via the toolbar button.

Image

Nesting a bullet list within an ordered list by indenting and then switching the list type via the toolbar button.

Image

What happened instead:
Trying to nest an ordered list within a bullet list switches the parent list to ordered format instead.

Image

Trying to nest a bullet list within an ordered list does nothing.

Steps to reproduce:
Reproducible in the react-admin-demo

Related code:
The list buttons of the ra-input-rich-text module have logic that seem to depend on the specific order
of the ListValues array.

  1. handleUpdate
ListValues.reduce((acc, value) => {
                    if (editor && editor.isActive(value)) {
                        return value;
                    }
                    return acc;
                }

always returns the last element in ListValues ("orderedList") if both are active.

  1. handleChange
ListValues.forEach(format => {
            const shouldBeDeactivated =
                editor && editor.isActive(format) && newFormat !== format;
            const shouldBeActivated =
                editor && !editor.isActive(format) && newFormat === format;

            if (shouldBeDeactivated || shouldBeActivated) {
                ListActions[format](editor);
            }
})

equally does not look for the innermost list, leading to strange toggling behavior for nested lists.

Environment

  • React-admin version: >=5.0.0
  • React version: >= 19.0.0
  • Browser: Chrome 145.0 / Firefox 148.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions