Repository navigation
[20.0][MIG] web_remember_tree_column_width: Migration to 20.0 - #3751
mcastillol14 wants to merge 30 commits into
Conversation
… widths Remember the tree columns' widths across sessions, and after filtering, grouping, or reordering.
this fixes scss file not found error after installing the module
…on column Fix an error when retrieving column sizes for lists containing one or more list_button columns. This error occurs when a list_button column is placed between other columns in the list. This type of column is excluded from the querySelector string used to retrieve column headers, which can cause the index to shift and the column size to change when the list is displayed.
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: web-17.0/web-17.0-web_remember_tree_column_width Translate-URL: https://translation.odoo-community.org/projects/web-17-0/web-17-0-web_remember_tree_column_width/
Co-authored-by: Stefan Rijnhart <stefan@opener.amsterdam>
Fixes ``` Uncaught Javascript Error > Cannot read properties of undefined (reading 'isRTL') ``` when trying to resizing a column in a list view. Caused by upstream change odoo/odoo#210559
Analogous to the inherited code, the event listener would work on the resize stop event, but this event would regularly not have the same target as the resize start event in which case the field name and size could not be determined.
BhaveshHeliconia
left a comment
There was a problem hiding this comment.
Functionally not working
Quotations.mp4
|
Thanks for testing this and recording the video, @BhaveshHeliconia — you were right, it was functionally broken. I set up a real Odoo 20.0 instance (official Root cause: the migration only bumped the version number but missed several real breaking changes in the OWL version shipped with 20.0 (signal-based reactivity):
Just pushed a fix with all of the above. Verified against a real Odoo 20.0 container: resizing a column and reloading the page now keeps the new width, with no console errors. Could you re-test when you have a chance? |
|
Functionally working now, But squash the last commit into the migration commit. |
125b1d8 to
cb599b3
Compare
|
Done, squashed the fix into the migration commit. Thanks for confirming it's working! |
XtremXpert
left a comment
There was a problem hiding this comment.
Functional check on a Odoo 20.0 database (module installed, list view opened in a browser).
What I could verify:
- the restore side works: I seeded
odoo.columnWidth.resource.booking.type.name = 300inlocalStorage, reloaded the list, and thenamecolumn renders at 300px (th.style.width = "300px"), with the other columns keeping their magic width; - the patch relies on
ListRenderer.useMagicColumnWidths, which is still a truthy class property in 20.0 (list_renderer.js), sosetStoredColumnWidthsis actually called on mount and on window resize; - wrapping
columnWidths.onStartResizedoes not break the upstream resize: the original handler only uses its closure variables, so calling it through the wrapper object is safe.
What I could not verify: the save side. The .o_resize handle has a zero-size bounding box, so a scripted pointer drag does not trigger onStartResize; I only checked that path by reading the code. Since the module is JS-only and has no test suite, a manual "resize a column, reload, width kept" by the reviewer would be worth it.
CI is green and the code follows the 20.0 column_width_hook API. Nothing blocking from my side.
XtremXpert
left a comment
There was a problem hiding this comment.
Functional validation complete on a Odoo 20.0 instance.
Both sides of the feature are now verified in a real browser:
- save: resizing the "Name" column of a list view and reloading keeps the new width, and the value is stored under
odoo.columnWidth.resource.booking.type.nameinlocalStorage; - restore: a pre-seeded width (
300) is applied on load (th.style.width = "300px"), including after a full reload.
Scope of the check: a plain list view. I did not exercise grouped lists or the export/optional-column cases.
CI is green and the code follows the 20.0 column_width_hook API (ListRenderer.useMagicColumnWidths is still a class property, and wrapping columnWidths.onStartResize does not break the upstream resize).
Approving from my side — thanks.
|
This PR has the |
StefanRijnhart
left a comment
There was a problem hiding this comment.
Thanks. Please update PR comment with the eventual changes and update commit message with Assisted-by trailer required by https://github.com/OCA/.github/blob/master/AI_POLICY.md
|
/ocabot migration web_remember_tree_column_width |
StefanRijnhart
left a comment
There was a problem hiding this comment.
Oh, there is a functional issue. See this video in which the opened menu shows my custom widths, and removing the filter resets to the standard widths:
output.webm
Claude suggests:
useEffect behaves differently in Odoo 20.0, so saved widths probably get overwritten (major)
list_renderer.esm.js uses useEffect(setStoredColumnWidths) from @odoo/owl.
- Before: in Owl 2 (Odoo's frontend framework up to 19.0), useEffect with no dependencies ran after every mount and every re-render. Because the patch registers it after Odoo's own hook, the saved widths were applied after Odoo set its computed ones.
- Now: in Owl 3, useEffect is a signal effect (owl.js:1728). It reruns only when a signal it reads changes, not after each render.
- Effect: Odoo's column-width hook still recomputes widths on every render (onMounted/onPatched(forceColumnWidths) in column_width_hook.js:565) and writes its cached computed widths to the header cells each time. Those writes will usually win, so after
filtering, grouping or any other re-render the saved widths are probably lost. That is exactly what the module is supposed to prevent. I haven't run it, so this is from reading the code; please check it in a browser. - Fix: Odoo's compatibility layer exists for this case (web/static/src/owl2/owl3_compatibility_layer.js:19): "replace all useEffect with useLayoutEffect". useLayoutEffect(setStoredColumnWidths) brings back the old run-after-every-render behaviour.
Another, unrelated suggestion:
A pointercancel event leaves the module's listener behind. In 20.0, Odoo's resize code also stops on pointercancel (column_width_hook.js:489, e.g. touch scrolling on a tablet). The module's own list still has only ["keydown", "pointerdown", "pointerup"]. After a cancelled resize, its window listener stays
attached. The next keydown or pointerup anywhere then calls preventDefault() and stopPropagation() on that event, which can swallow a key press, and saves a width. Fix: add "pointercancel" to the list.
cb599b3 to
a922700
Compare
|
The following commit authors need to sign the Contributor License Agreement: |
|
Thanks for the detailed analysis and video, and for having your own Claude dig into the exact mechanism. Applied your suggested fix ( Full transparency on verification: I set up a real Odoo 20.0 Docker instance (built Could you re-test with this commit on your end and confirm whether the filter-removal scenario from your video is now fixed? |
|
Done, picked it: 9211e6d |
|
@mcastillol14 You need to cherry-pick that commit before your migration commit instead of adding it directly. |
9211e6d to
8d44291
Compare
|
You're right, fixed it — cherry-picked your original commit (400be12) preserving your authorship, with our migration commit rebased on top. |
Standard migration of
web_remember_tree_column_widthto 20.0, following the usualgit format-patch/git amprocedure to preserve commit history and authorship. Only change needed: manifest version bump to20.0.1.0.0. No code changes (single JS asset, no Python, no tests).