-
Notifications
You must be signed in to change notification settings - Fork 30.4k
[FIX] web: Prevent focusCell() error on destroyed components #232156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] web: Prevent focusCell() error on destroyed components #232156
Conversation
|
@shku-odoo @aab-odoo cherrypicking of pull request #232097 failed. stdout: Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?). In the former case, you may want to edit this PR message as well. More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port |
|
@shku-odoo @aab-odoo this forward port of #232097 is awaiting action (not merged or closed). |
|
@shku-odoo don't forget this forwardport. There's a small conflict to resolve. Thanks |
|
@shku-odoo @aab-odoo this forward port of #232097 is awaiting action (not merged or closed). |
cfffaf1 to
ab0cfb1
Compare
aab-odoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
robodoo r+
|
@shku-odoo @aab-odoo 'ci/runbot' failed on this reviewed PR. |
ab0cfb1 to
0bc73ce
Compare
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
X-original-commit: c4ec69a
0bc73ce to
a1d7cc1
Compare
aab-odoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
robodoo r+
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 #232156
X-original-commit: c4ec69a
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
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>
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>
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>

Steps to Reproduce:
Traceback:
Root Cause:
Fix:
if (status(this) === destroyed) return;to stop focusCell() execution on destroyed components.onWillDestroyto clean up dialog callbacks, preventing memory leaks.OPW - 5154694
PAD
Localhost issue reproduction steps
17:
odoo/addons/web/static/src/views/list/list_renderer.js
Line 223 in f9726cf
18:
odoo/addons/web/static/src/views/list/list_renderer.js
Line 213 in 1cac54d
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Forward-Port-Of: #232097