Skip to content

Commit d22b97d

Browse files
committed
fix: better event handling
1 parent 135a63a commit d22b97d

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

src/containers/DrawerWrapper/DrawerWrapper.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ export const DrawerContentWrapper = ({
5555
}
5656
};
5757

58-
document.addEventListener('mousedown', handleClickOutside);
58+
document.addEventListener('click', handleClickOutside);
5959
return () => {
60-
document.removeEventListener('mousedown', handleClickOutside);
60+
document.removeEventListener('click', handleClickOutside);
6161
};
6262
}, [isVisible, onClose, detectClickOutside]);
6363

@@ -114,6 +114,11 @@ export const DrawerWrapper = ({
114114
className,
115115
detectClickOutside,
116116
}: DrawerWrapperProps) => {
117+
React.useEffect(() => {
118+
return () => {
119+
onCloseDrawer();
120+
};
121+
}, [onCloseDrawer]);
117122
return (
118123
<React.Fragment>
119124
{children}

src/containers/Tenant/Diagnostics/TopQueries/RunningQueriesData.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ export const RunningQueriesData = ({
7373
const rows = data?.resultSets?.[0]?.result;
7474
const {handleRowSelect, selectedRow, hasSearchParams} = useRunningQueriesRowSelection(rows);
7575

76-
const handleRowClick = (row: KeyValueRow) => {
77-
// Simply pass the row to handleRowSelect
78-
handleRowSelect(row);
79-
};
80-
8176
const handleCloseDetails = React.useCallback(() => {
8277
handleRowSelect(null);
8378
}, [handleRowSelect]);
@@ -127,7 +122,7 @@ export const RunningQueriesData = ({
127122
data={rows || []}
128123
loading={isFetching && currentData === undefined}
129124
settings={TOP_QUERIES_TABLE_SETTINGS}
130-
onRowClick={handleRowClick}
125+
onRowClick={handleRowSelect}
131126
rowClassName={(row) => b('row', {active: row === selectedRow})}
132127
sortOrder={tableSort}
133128
onSort={handleTableSort}

src/containers/Tenant/Diagnostics/TopQueries/hooks/useRunningQueriesRowSelection.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ export function useRunningQueriesRowSelection(rows?: KeyValueRow[] | null) {
5050
const matchedRow = findMatchedQueryRow();
5151

5252
const handleRowSelect = React.useCallback(
53-
(row: KeyValueRow | null) => {
53+
(
54+
row: KeyValueRow | null,
55+
_index?: number,
56+
event?: React.MouseEvent<HTMLTableRowElement>,
57+
) => {
58+
event?.stopPropagation();
59+
5460
if (!row) {
5561
setQueryParams(
5662
{

src/containers/Tenant/Diagnostics/TopQueries/hooks/useTopQueriesRowSelection.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ export function useTopQueriesRowSelection(rows?: KeyValueRow[] | null) {
5454
const matchedRow = findMatchedQueryRow();
5555

5656
const handleRowSelect = React.useCallback(
57-
(row: KeyValueRow | null) => {
57+
(
58+
row: KeyValueRow | null,
59+
_index?: number,
60+
event?: React.MouseEvent<HTMLTableRowElement>,
61+
) => {
62+
event?.stopPropagation();
63+
5864
if (!row) {
5965
setQueryParams(
6066
{

0 commit comments

Comments
 (0)