mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix(core-app): CB-863 remove default onClick behavior from TreeNodeControl
This commit is contained in:
+6
-2
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { useContext } from 'react';
|
||||
import { useCallback, useContext } from 'react';
|
||||
import styled, { css } from 'reshadow';
|
||||
|
||||
import { TreeNodeContext, TreeNodeControl, TreeNodeExpand, TreeNodeIcon, TreeNodeName, TREE_NODE_STYLES } from '@cloudbeaver/core-blocks';
|
||||
@@ -71,8 +71,12 @@ export const NavigationNodeControl: React.FC<Props> = observer(function Navigati
|
||||
connected = !!connectionInfo?.connected;
|
||||
}
|
||||
|
||||
const onClickHandler = useCallback((event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
||||
context?.select(event.ctrlKey || event.metaKey);
|
||||
}, [context]);
|
||||
|
||||
return styled(useStyles(TREE_NODE_STYLES, styles))(
|
||||
<TreeNodeControl>
|
||||
<TreeNodeControl onClick={onClickHandler}>
|
||||
<TreeNodeExpand />
|
||||
<TreeNodeIcon icon={node.icon}>
|
||||
{connected && <status as='div' />}
|
||||
|
||||
@@ -15,11 +15,13 @@ const KEY = {
|
||||
};
|
||||
|
||||
interface Props {
|
||||
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
||||
className?: string;
|
||||
big?: boolean;
|
||||
}
|
||||
|
||||
export const TreeNodeControl: React.FC<Props> = function TreeNodeControl({
|
||||
onClick,
|
||||
className,
|
||||
children,
|
||||
}) {
|
||||
@@ -41,7 +43,10 @@ export const TreeNodeControl: React.FC<Props> = function TreeNodeControl({
|
||||
|
||||
const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {
|
||||
event.stopPropagation();
|
||||
context?.select(event.ctrlKey || event.metaKey);
|
||||
|
||||
if (onClick) {
|
||||
onClick(event);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user