Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/containers/Versions/NodesTreeTitle/NodesTreeTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ export const NodesTreeTitle = ({
preparedVersions,
onClick,
}: NodesTreeTitleProps) => {
const handleClick = React.useCallback<React.MouseEventHandler<HTMLDivElement>>(
(event) => {
const shouldSkip = event.nativeEvent.composedPath().some(isActiveButtonTarget);

if (!shouldSkip) {
onClick?.();
}
},
[onClick],
);

const nodesAmount = React.useMemo(() => {
if (items) {
return items.reduce((acc, curr) => {
Expand All @@ -49,7 +60,7 @@ export const NodesTreeTitle = ({
}, [items, nodes]);

return (
<div className={b('overview')} onClick={onClick}>
<div className={b('overview')} onClick={handleClick}>
<Flex gap={2} alignItems={'center'}>
{versionColor && !isDatabase ? (
<div className={b('version-color')} style={{background: versionColor}} />
Expand All @@ -63,10 +74,6 @@ export const NodesTreeTitle = ({
size="s"
className={b('clipboard-button')}
view="flat"
onClickCapture={(e) => {
e.preventDefault();
e.stopPropagation();
}}
/>
</React.Fragment>
) : null}
Expand All @@ -85,3 +92,11 @@ export const NodesTreeTitle = ({
</div>
);
};

function isActiveButtonTarget(target: EventTarget) {
return (
target instanceof HTMLElement &&
((target.nodeName === 'BUTTON' && !target.hasAttribute('disabled')) ||
(target.hasAttribute('tabindex') && target.tabIndex > -1))
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic checks for non-disabled buttons but doesn't account for buttons that might be disabled via CSS or aria-disabled. Consider also checking target.disabled property for button elements and aria-disabled attribute.

Suggested change
((target.nodeName === 'BUTTON' && !target.hasAttribute('disabled')) ||
(target.hasAttribute('tabindex') && target.tabIndex > -1))
(
(target.nodeName === 'BUTTON'
&& !(target as HTMLButtonElement).disabled
&& target.getAttribute('aria-disabled') !== 'true'
&& !target.hasAttribute('disabled')
)
||
(target.hasAttribute('tabindex') && target.tabIndex > -1)
)

Copilot uses AI. Check for mistakes.
);
}
Loading