Skip to content

Commit 66ecf28

Browse files
authored
fix: Scroll to trace in structure tab (#827)
1 parent 9a4d455 commit 66ecf28

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/pages/Explore/Drawer.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export function Drawer({
8484
open={true}
8585
onClose={onClose}
8686
placement="right"
87-
getContainer={'#trace-exploration'}
87+
// Portal to body with position:fixed so scroll inside #trace-exploration cannot hide the drawer.
88+
getContainer={() => document.body}
8889
className={styles.drawerContent}
8990
rootClassName={styles.drawer}
9091
classNames={{
@@ -210,10 +211,9 @@ function useResizebleDrawer(): [
210211
function getCustomDrawerWidth(clientX: number) {
211212
const traceExploration = document.getElementById('trace-exploration');
212213
if (traceExploration) {
213-
const traceExplorationWidth = traceExploration.offsetWidth;
214-
const offsetLeft = traceExploration.offsetLeft;
215-
const offsetRight = traceExplorationWidth - (clientX - offsetLeft);
216-
const widthPercent = Math.min((offsetRight / traceExplorationWidth) * 100, 98).toFixed(2);
214+
const rect = traceExploration.getBoundingClientRect();
215+
const offsetRight = rect.right - clientX;
216+
const widthPercent = Math.min((offsetRight / rect.width) * 100, 98).toFixed(2);
217217
return `${widthPercent}%`;
218218
}
219219
return '50%';
@@ -244,8 +244,9 @@ const getStyles = (theme: GrafanaTheme2) => {
244244
position: 'relative',
245245
}),
246246
drawer: css({
247-
top: 0,
248-
position: 'absolute !important' as 'absolute',
247+
position: 'fixed !important' as 'fixed',
248+
inset: 0,
249+
zIndex: theme.zIndex.modal,
249250

250251
'.rc-drawer-content-wrapper': {
251252
boxShadow: theme.shadows.z3,

0 commit comments

Comments
 (0)