Skip to content

Commit 35d1388

Browse files
colin-sentryandrewshie-sentry
authored andcommitted
chore(ourlogs): Do not expand the row if you click the context menu (#90086)
It's difficult to use `e.stopPropagation();` in the menu element, so instead check the target for the pointer event and bail if it's a button.
1 parent 1c6f8d6 commit 35d1388

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

static/app/views/explore/logs/logsTableRow.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type {SyntheticEvent} from 'react';
12
import {Fragment, useCallback, useState} from 'react';
23
import {useTheme} from '@emotion/react';
34

@@ -62,6 +63,21 @@ type LogsRowProps = {
6263

6364
const ALLOWED_CELL_ACTIONS: Actions[] = [Actions.ADD, Actions.EXCLUDE];
6465

66+
function isInsideButton(element: Element | null): boolean {
67+
let i = 10;
68+
while (element && i > 0) {
69+
i -= 1;
70+
if (
71+
element instanceof HTMLButtonElement ||
72+
element.getAttribute('role') === 'button'
73+
) {
74+
return true;
75+
}
76+
element = element.parentElement;
77+
}
78+
return false;
79+
}
80+
6581
export function LogRowContent({
6682
dataRow,
6783
highlightTerms,
@@ -74,7 +90,11 @@ export function LogRowContent({
7490
const search = useLogsSearch();
7591
const setLogsSearch = useSetLogsSearch();
7692

77-
function onPointerUp() {
93+
function onPointerUp(event: SyntheticEvent) {
94+
if (event.target instanceof Element && isInsideButton(event.target)) {
95+
// do not expand the context menu if you clicked a button
96+
return;
97+
}
7898
if (window.getSelection()?.toString() === '') {
7999
setExpanded(e => !e);
80100
trackAnalytics('logs.table.row_expanded', {

0 commit comments

Comments
 (0)