Commit 2e9e99c
[FIX] web: Prevent focusCell() error on destroyed components
Steps to Reproduce:
- Open a Repair Order form view in Odoo 17 or 18.
- Navigate to the Parts tab.
- In the list view of parts, click the Smart Button on any part line.
- A pop-up form view opens showing detailed operations.
- Click the “Pick From” field value, but don't change its value.
- Click the Save button in the pop-up.
- Observe the browser console for the error:
TypeError: Cannot read properties of null (reading 'querySelector')
at ListRenderer.focusCell
Root Cause:
- Asynchronous patching in OWL (onPatched with await Promise.resolve())
continues execution after the next tick, even if the component is destroyed.
- When the component is destroyed, OWL sets status(this) = 3 (DESTROYED).
- focusCell() accesses DOM using querySelector, which fails if the component is
destroyed.
- The code did not check the component status before calling focusCell().
Fix:
- Added `if (status(this) === destroyed) return;` to stop focusCell()
execution on destroyed components.
- Ensured async patching is handled safely with await Promise.resolve().
17: https://github.com/odoo/odoo/blob/f9726cfe93e8850a38d9de06acfa5d78473b50b0/addons/web/static/src/views/list/list_renderer.js#L223
18: https://github.com/odoo/odoo/blob/1cac54db8634267a780b4011291f1e8a80ac5f5b/addons/web/static/src/views/list/list_renderer.js#L213
closes odoo#232156
X-original-commit: c4ec69a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>1 parent 3e384c3 commit 2e9e99c
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
217 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
218 | 221 | | |
219 | 222 | | |
220 | 223 | | |
| |||
0 commit comments