Skip to content

Commit c7d2eed

Browse files
fix(Versions): fix version copy (#2755)
1 parent d08c5db commit c7d2eed

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/containers/Versions/NodesTreeTitle/NodesTreeTitle.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ export const NodesTreeTitle = ({
3535
preparedVersions,
3636
onClick,
3737
}: NodesTreeTitleProps) => {
38+
const handleClick = React.useCallback<React.MouseEventHandler<HTMLDivElement>>(
39+
(event) => {
40+
const shouldSkip = event.nativeEvent.composedPath().some(isActiveButtonTarget);
41+
42+
if (!shouldSkip) {
43+
onClick?.();
44+
}
45+
},
46+
[onClick],
47+
);
48+
3849
const nodesAmount = React.useMemo(() => {
3950
if (items) {
4051
return items.reduce((acc, curr) => {
@@ -49,7 +60,7 @@ export const NodesTreeTitle = ({
4960
}, [items, nodes]);
5061

5162
return (
52-
<div className={b('overview')} onClick={onClick}>
63+
<div className={b('overview')} onClick={handleClick}>
5364
<Flex gap={2} alignItems={'center'}>
5465
{versionColor && !isDatabase ? (
5566
<div className={b('version-color')} style={{background: versionColor}} />
@@ -63,10 +74,6 @@ export const NodesTreeTitle = ({
6374
size="s"
6475
className={b('clipboard-button')}
6576
view="flat"
66-
onClickCapture={(e) => {
67-
e.preventDefault();
68-
e.stopPropagation();
69-
}}
7077
/>
7178
</React.Fragment>
7279
) : null}
@@ -85,3 +92,13 @@ export const NodesTreeTitle = ({
8592
</div>
8693
);
8794
};
95+
96+
function isActiveButtonTarget(target: EventTarget) {
97+
return (
98+
target instanceof HTMLElement &&
99+
((target.nodeName === 'BUTTON' &&
100+
!target.hasAttribute('disabled') &&
101+
target.getAttribute('aria-disabled') !== 'true') ||
102+
(target.hasAttribute('tabindex') && target.tabIndex > -1))
103+
);
104+
}

0 commit comments

Comments
 (0)