-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4346] Improve the performance of the Query view with large sets of data
Bug: #4346 Signed-off-by: Stéphane Bégaudeau <[email protected]>
- Loading branch information
1 parent
979953f
commit 9a03eca
Showing
9 changed files
with
182 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...sirius-web-application/src/views/edit-project/workbench-views/query/useResultAreaSize.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
import { useEffect, useRef, useState } from 'react'; | ||
import { UseResultAreaSizeState, UseResultAreaSizeValue } from './useResultAreaSize.types'; | ||
|
||
export const useResultAreaSize = (): UseResultAreaSizeValue => { | ||
const [state, setState] = useState<UseResultAreaSizeState>({ | ||
height: null, | ||
width: null, | ||
}); | ||
|
||
const ref = useRef<HTMLDivElement | null>(null); | ||
|
||
useEffect(() => { | ||
if (!ref.current) { | ||
return () => {}; | ||
} | ||
const parentDiv = ref.current; | ||
const expressionDiv: HTMLDivElement | null = parentDiv.querySelector('[data-role="expression"]'); | ||
const resultDiv: HTMLDivElement | null = parentDiv.querySelector('[data-role="result"]'); | ||
|
||
const resizeObserver = new ResizeObserver(() => { | ||
if (expressionDiv && resultDiv) { | ||
const height = (parentDiv.offsetHeight - expressionDiv.offsetHeight) * 0.85; | ||
const width = expressionDiv.offsetWidth; | ||
|
||
setState((prevState) => ({ | ||
...prevState, | ||
height, | ||
width, | ||
})); | ||
} | ||
}); | ||
|
||
resizeObserver.observe(ref.current); | ||
|
||
return () => resizeObserver.disconnect(); | ||
}, [ref.current]); | ||
|
||
return { | ||
ref, | ||
height: state.height, | ||
width: state.width, | ||
}; | ||
}; |
Oops, something went wrong.