odoo/odoo#263164

Created by fw-bot
Merged at b005d8d65687e5ddeeeca3206510033365bda70e

Statuses:

label
odoo-dev:saas-19.3-18.0-opw-6142055-preserve_selection_on_delete-wasa-524116-fw
head
70369489263847387566b95eb7ae57fa395a068a
merged
2 days 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: #262896
Forward-Port-Of: #260630