Skip to content

Commit

Permalink
[FIX] spreadsheet: fix useSpreadsheetRect
Browse files Browse the repository at this point in the history
The hook `useSpreadsheetRect` was doing a querySelector(".o-spreadsheet")
as soon as it was called, instead of waiting for the `onMounted`.

That meant that when creating a new spreadsheet component after
destroying another, the hook would return the rect of the old
spreadsheet.

closes #4370

Task: 3965147
X-original-commit: 402bf1d
Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Signed-off-by: Adrien Minne (adrm) <adrm@odoo.com>
  • Loading branch information
hokolomopo committed Jun 6, 2024
1 parent ac0927e commit 4538da2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/components/helpers/position_hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ type Ref = ReturnType<typeof useRef>;
*/
export function useSpreadsheetRect(): Rect {
const position = useState({ x: 0, y: 0, width: 0, height: 0 });
let spreadsheetElement = document.querySelector(".o-spreadsheet");
updatePosition();
let spreadsheetElement: Element | null = null;
function updatePosition() {
if (!spreadsheetElement) {
spreadsheetElement = document.querySelector(".o-spreadsheet");
Expand Down

0 comments on commit 4538da2

Please sign in to comment.