Skip to content

Commit f48d9c3

Browse files
rrahirfw-bot
authored andcommitted
Cherry pick of 8d29c2c failed
stdout: Auto-merging src/components/helpers/dom_helpers.ts CONFLICT (content): Merge conflict in src/components/helpers/dom_helpers.ts Auto-merging tests/grid/__snapshots__/dashboard_grid_component.test.ts.snap Auto-merging tests/grid/__snapshots__/grid_component.test.ts.snap Auto-merging tests/spreadsheet/__snapshots__/spreadsheet_component.test.ts.snap stderr:
1 parent bc4308a commit f48d9c3

File tree

13 files changed

+63
-76
lines changed

13 files changed

+63
-76
lines changed

src/components/helpers/dom_helpers.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ export function isCtrlKey(ev: KeyboardEvent | MouseEvent): boolean {
187187
}
188188

189189
/**
190+
<<<<<<< bc4308a91b3814c2e08acc2b500a41cd83e50355
190191
* @param {MouseEvent} ev - The mouse event.
191192
* @returns {boolean} Returns true if the event was triggered by a middle-click
192193
* or a Ctrl + Click (Cmd + Click on Mac).
@@ -219,4 +220,11 @@ export function downloadFile(dataUrl: string, fileName: string) {
219220
document.body.appendChild(a);
220221
a.click();
221222
document.body.removeChild(a);
223+
||||||| ee38511eee6ff824406112ca8e6efeff9b41ddfd
224+
=======
225+
* Detects if the current browser is Firefox
226+
*/
227+
export function isBrowserFirefox() {
228+
return /Firefox/i.test(navigator.userAgent);
229+
>>>>>>> 8d29c2c115b43e1991e7f8be75380b6a43c5e874
222230
}

src/components/scrollbar/scrollbar_horizontal.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, xml } from "@odoo/owl";
22
import { SCROLLBAR_WIDTH } from "../../constants";
33
import { SpreadsheetChildEnv } from "../../types";
4+
import { isBrowserFirefox } from "../helpers/dom_helpers";
45
import { ScrollBar } from "./scrollbar";
56

67
interface Props {
@@ -46,7 +47,7 @@ export class HorizontalScrollBar extends Component<Props, SpreadsheetChildEnv> {
4647
left: `${this.props.leftOffset + x}px`,
4748
bottom: "0px",
4849
height: `${SCROLLBAR_WIDTH}px`,
49-
right: `0px`,
50+
right: isBrowserFirefox() ? `${SCROLLBAR_WIDTH}px` : "0",
5051
};
5152
}
5253

src/components/scrollbar/scrollbar_vertical.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Component, xml } from "@odoo/owl";
22
import { SCROLLBAR_WIDTH } from "../../constants";
33
import { SpreadsheetChildEnv } from "../../types";
4+
import { isBrowserFirefox } from "../helpers/dom_helpers";
45
import { ScrollBar } from "./scrollbar";
56

67
interface Props {
@@ -46,7 +47,7 @@ export class VerticalScrollBar extends Component<Props, SpreadsheetChildEnv> {
4647
top: `${this.props.topOffset + y}px`,
4748
right: "0px",
4849
width: `${SCROLLBAR_WIDTH}px`,
49-
bottom: `0px`,
50+
bottom: isBrowserFirefox() ? `${SCROLLBAR_WIDTH}px` : "0",
5051
};
5152
}
5253

src/components/spreadsheet/spreadsheet.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ css/* scss */ `
224224
> canvas {
225225
box-sizing: content-box;
226226
border-bottom: 1px solid #e2e3e3;
227+
border-right: 1px solid #e2e3e3;
227228
}
228229
229230
.o-grid-overlay {

src/helpers/internal_viewport.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DEFAULT_CELL_HEIGHT, DEFAULT_CELL_WIDTH, FOOTER_HEIGHT } from "../constants";
1+
import { FOOTER_HEIGHT } from "../constants";
22
import {
33
DOMCoordinates,
44
DOMDimension,
@@ -74,35 +74,17 @@ export class InternalViewport {
7474
first: this.boundaries.top,
7575
last: this.boundaries.bottom,
7676
});
77-
const { end: lastColEnd, size: lastColSize } = this.getters.getColDimensions(
78-
this.sheetId,
79-
lastCol
80-
);
81-
const { end: lastRowEnd, size: lastRowSize } = this.getters.getRowDimensions(
82-
this.sheetId,
83-
lastRow
84-
);
8577

86-
const leftColIndex = this.searchHeaderIndex("COL", lastColEnd - this.viewportWidth, 0);
87-
const leftColSize = this.getters.getColSize(this.sheetId, leftColIndex);
88-
const leftRowIndex = this.searchHeaderIndex("ROW", lastRowEnd - this.viewportHeight, 0);
89-
const topRowSize = this.getters.getRowSize(this.sheetId, leftRowIndex);
78+
const { end: lastColEnd } = this.getters.getColDimensions(this.sheetId, lastCol);
79+
const { end: lastRowEnd } = this.getters.getRowDimensions(this.sheetId, lastRow);
9080

9181
let width = lastColEnd - this.offsetCorrectionX;
9282
if (this.canScrollHorizontally) {
93-
width += Math.max(
94-
DEFAULT_CELL_WIDTH, // leave some minimal space to let the user know they scrolled all the way
95-
Math.min(leftColSize, this.viewportWidth - lastColSize) // Add pixels that allows the snapping at maximum horizontal scroll
96-
);
9783
width = Math.max(width, this.viewportWidth); // if the viewport grid size is smaller than its client width, return client width
9884
}
9985

10086
let height = lastRowEnd - this.offsetCorrectionY;
10187
if (this.canScrollVertically) {
102-
height += Math.max(
103-
DEFAULT_CELL_HEIGHT + 5, // leave some space to let the user know they scrolled all the way
104-
Math.min(topRowSize, this.viewportHeight - lastRowSize) // Add pixels that allows the snapping at maximum vertical scroll
105-
);
10688
height = Math.max(height, this.viewportHeight); // if the viewport grid size is smaller than its client height, return client height
10789

10890
if (lastRowEnd + FOOTER_HEIGHT > height && !this.getters.isReadonly()) {

src/plugins/ui_stateful/sheetview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,8 @@ export class SheetViewPlugin extends UIPlugin {
402402
const { width, height } = this.getMainViewportRect();
403403
const viewport = this.getMainInternalViewport(sheetId);
404404
return {
405-
maxOffsetX: Math.max(0, width - viewport.viewportWidth + 1),
406-
maxOffsetY: Math.max(0, height - viewport.viewportHeight + 1),
405+
maxOffsetX: Math.max(0, width - viewport.viewportWidth),
406+
maxOffsetY: Math.max(0, height - viewport.viewportHeight),
407407
};
408408
}
409409

tests/__snapshots__/renderer_store.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports[`renderer snapshot for a simple grid rendering 1`] = `
77
"context.fillRect(0, 0, 952.5, 974.5)",
88
"context.save()",
99
"context.beginPath()",
10-
"context.rect(0, 0, 2592, 2374)",
10+
"context.rect(0, 0, 2496, 2346)",
1111
"context.clip()",
1212
"context.strokeStyle="#E2E3E3";",
1313
"context.lineWidth=0.4;",

tests/grid/__snapshots__/dashboard_grid_component.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,19 @@ exports[`Grid component in dashboard mode simple dashboard rendering snapshot 1`
4646
</div>
4747
<div
4848
class="o-scrollbar vertical"
49-
style="top:0px; right:0px; width:15px; bottom:0px; "
49+
style="top:0px; right:0px; width:15px; bottom:0; "
5050
>
5151
<div
52-
style="width:1px; height:2328px; "
52+
style="width:1px; height:2300px; "
5353
/>
5454
</div>
5555
5656
<div
5757
class="o-scrollbar horizontal"
58-
style="left:0px; bottom:0px; height:15px; right:0px; "
58+
style="left:0px; bottom:0px; height:15px; right:0; "
5959
>
6060
<div
61-
style="width:2592px; height:1px; "
61+
style="width:2496px; height:1px; "
6262
/>
6363
</div>
6464

tests/grid/__snapshots__/grid_component.test.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,19 @@ exports[`Grid component simple rendering snapshot 1`] = `
128128
129129
<div
130130
class="o-scrollbar vertical"
131-
style="top:26px; right:0px; width:15px; bottom:0px; "
131+
style="top:26px; right:0px; width:15px; bottom:0; "
132132
>
133133
<div
134-
style="width:1px; height:2374px; "
134+
style="width:1px; height:2346px; "
135135
/>
136136
</div>
137137
138138
<div
139139
class="o-scrollbar horizontal"
140-
style="left:48px; bottom:0px; height:15px; right:0px; "
140+
style="left:48px; bottom:0px; height:15px; right:0; "
141141
>
142142
<div
143-
style="width:2592px; height:1px; "
143+
style="width:2496px; height:1px; "
144144
/>
145145
</div>
146146

tests/sheet/sheet_manipulation_plugin.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -941,8 +941,8 @@ describe("Rows", () => {
941941
});
942942
const newDimensions = model.getters.getMainViewportRect();
943943
expect(newDimensions).toMatchObject({
944-
width: 192, // col size + 1 DEFAULT_CELL_WIDTH for spacing
945-
height: 170, // sum of row sizes + 1 DEFAULT_CELL_HEIGHT + 5px for spacing + 46px for adding rows footer
944+
width: DEFAULT_CELL_WIDTH, // sum of col sizes
945+
height: 142, // sum of row sizes + 46px for adding rows footer
946946
});
947947
});
948948
test("On addition after", () => {
@@ -963,8 +963,8 @@ describe("Rows", () => {
963963
});
964964
const newDimensions = model.getters.getMainViewportRect();
965965
expect(newDimensions).toMatchObject({
966-
width: 192, // col size + 1 DEFAULT_CELL_WIDTH for spacing
967-
height: 190, // sum of row sizes + 1 DEFAULT_CELL_HEIGHT and 5px for spacing + 46px for adding rows footer
966+
width: DEFAULT_CELL_WIDTH, // sum of col sizes
967+
height: 162, // sum of row sizes + 46px for adding rows footer
968968
});
969969
expect(model.getters.getNumberRows(sheetId)).toBe(6);
970970
});
@@ -983,16 +983,16 @@ describe("Rows", () => {
983983
});
984984
let dimensions = model.getters.getMainViewportRect();
985985
expect(dimensions).toMatchObject({
986-
width: 192, // col size + 1 DEFAULT_CELL_WIDTH for spacing
987-
height: 170, // sum of row sizes + 1 DEFAULT_CELL_HEIGHT and 5px for spacing + 46px for adding rows footer
986+
width: DEFAULT_CELL_WIDTH, // sum of col sizes
987+
height: 142, // sum of row sizes + 46px for adding rows footer
988988
});
989989
const to = model.getters.getActiveSheetId();
990990
createSheet(model, { activate: true, sheetId: "42" });
991991
activateSheet(model, to);
992992
dimensions = model.getters.getMainViewportRect();
993993
expect(dimensions).toMatchObject({
994-
width: 192, // col size + 1 DEFAULT_CELL_WIDTH for spacing
995-
height: 170, // sum of row sizes + 1 DEFAULT_CELL_HEIGHT and 5px for spacing + 46px for adding rows footer
994+
width: DEFAULT_CELL_WIDTH, // sum of col sizes
995+
height: 142, // sum of row sizes + 46px for adding rows footer
996996
});
997997
});
998998
});

0 commit comments

Comments
 (0)