-
Notifications
You must be signed in to change notification settings - Fork 68
[FIX] dashboard: properly handle grid resize in dashboard mode #7404
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
base: saas-18.4
Are you sure you want to change the base?
Conversation
|
if I understand the issue correctly, we miss the actual computation of the spreadsheet width when in dashboard mode. have you looked into a way to correct that as well? because right now we have a discrepency between the canvas size and the actual part displayed to the client and I'm not sure that just hiding it is the best solution (maybe it's too complicated to fix and it's the right call, but i'm curious to know if looked into it) |
327e1bc to
4650b73
Compare
|
|
||
| onGridResized({ height, width }: DOMDimension) { | ||
| onGridResized() { | ||
| const rect = this.gridRef.el?.getBoundingClientRect(); |
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.
I fear this could break in later versions because of the introduction of the zoom (which still has to be implemented properly for dashboard but still) due to some weird stuff happening in safari which pretty much forces us to rely on the width and height because it is not affected similarly by the zoom depending on different browsers, see https://www.odoo.com/odoo/2328/tasks/5232092
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.
| const rect = this.gridRef.el?.getBoundingClientRect(); | |
| const { height } = this.props.getGridSize(); | |
| const sheetId = this.env.model.getters.getActiveSheetId(); | |
| const { right } = this.env.model.getters.getSheetZone(sheetId); | |
| const width = this.env.model.getters.getColDimensions(sheetId, right).end; |
this takes advantage of the future zoom issue and the computed width (something we already do in SpreadsheetDashboard.gridContainer) Wdyt?
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.
That solution doesn’t work because it sets a fixed max-width on the canvas on every resize, which doesn’t make sense and causes the layout bug. See the related issue here
I think we should fix this issue here, since this version doesn’t include Zoom functionality.
In the master, we’ll likely need to refactor the layout to align with the zoom behavior.
I’ll take some time to investigate what’s happening in the master 🥲
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.
Here is the diff I applied on my end, I did not experience the same issue as you do and when pushed it in Odoo ,I get the right positioning (and style) at first render

I rushed my explanation in my previous post but I think that it's a correct approach?
diff --git a/src/components/dashboard/dashboard.ts b/src/components/dashboard/dashboard.ts
index a54b218d57..96bf59dd45 100644
--- a/src/components/dashboard/dashboard.ts
+++ b/src/components/dashboard/dashboard.ts
@@ -103,8 +103,11 @@ export class SpreadsheetDashboard extends Component<Props, SpreadsheetChildEnv>
}
onGridResized({ height, width }: DOMDimension) {
+ const sheetId = this.env.model.getters.getActiveSheetId();
+ const { right } = this.env.model.getters.getSheetZone(sheetId);
+ const width2 = this.env.model.getters.getColDimensions(sheetId, right).end;
this.env.model.dispatch("RESIZE_SHEETVIEW", {
- width: width,
+ width: Math.min(width, width2),
height: height,
gridOffsetX: 0,
gridOffsetY: 0,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.
the diff was aplied in master but it's the same idea
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.
Honestly, that’s a brilliant move 🫡
4650b73 to
361261b
Compare
Before this commit: - The canvas size was computed from the grid, which caused visible white margins after a snappy resize (commit 3c8df4b). - Some unused props were being passed, creating unnecessary code clutter. After this commit: - The dashboard canvas size is now computed as the min of the grid bounds and the end of getColDimension. - Shows only visible parts and avoids extra canvas processing. Task: 5223156
361261b to
d525807
Compare

Description:
Current behavior before PR:
after a snappy resize (commit 3c8df4b9).
Desired behavior after PR is merged:
visible parts are displayed and avoiding redundant canvas computations.
Task: 5223156
review checklist