odoo/odoo#264167

Created by fw-bot
Merged at a60cd5265299f7c1e3d7d3a53993b78291567683

Statuses:

label
odoo-dev:master-18.0-opw-6142055-preserve_selection_on_delete-wasa-524161-fw
head
7c2ede0134ae6eb48ee0e7e6b5dcf320850607ea
merged
1 day ago by Walid Sahli (wasa)
odoo/odoo
18.0 #260630
saas-18.2 #262766
saas-18.3 #262845
saas-18.4 #262896
19.0 #263046
saas-19.1 #263109
saas-19.2 #263140
saas-19.3 #263164
master #264167

[FIX] html_editor: stage selection before deletion

Problem:
In some cases, undo restores the selection to an incorrect position.

Cause:
The selection state was not staged before the deletion started, leading to an inconsistent selection being restored during undo.

Solution:
Stage the selection before performing the deletion to ensure it can be restored to the correct position.

Steps to reproduce:
- Go to To-Do → Create New.
- Type something on the first line and press Enter.
- Type something on the second line and apply styling to it.
- Use the Up arrow key to move to the first line.
- Remove a character.
- Press Undo (Ctrl + Z).
- Observe that the selection and toolbar appear on the second line.

task-6142055


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #263164
Forward-Port-Of: #260630