goToEvent target handling
continuous-integration/drone/pr Build is failing Details

This commit is contained in:
Martti Malmi 2023-11-27 15:31:45 +02:00
parent 6b3102f30a
commit 9db117e270
3 changed files with 18 additions and 9 deletions

View File

@ -200,7 +200,7 @@ export function NoteContextMenu({ ev, ...props }: NosteContextMenuProps) {
<>
<Menu
menuButton={
<div className="reaction-pill">
<div className="reaction-pill cursor-pointer">
<Icon name="dots" size={15} />
</div>
}

View File

@ -316,7 +316,7 @@ const AsyncFooterIcon = forwardRef((props: AsyncIconProps & { value: number }, r
const mergedProps = {
...props,
iconSize: 18,
className: classNames("transition duration-200 ease-in-out reaction-pill", props.className),
className: classNames("transition duration-200 ease-in-out reaction-pill cursor-pointer", props.className),
};
return (

View File

@ -177,15 +177,24 @@ export function NoteInner(props: NoteProps) {
return innerContent;
};
function goToEvent(
e: React.MouseEvent,
eTarget: TaggedNostrEvent,
isTargetAllowed: boolean = e.target === e.currentTarget,
) {
if (!isTargetAllowed || opt?.canClick === false) {
function goToEvent(e: React.MouseEvent, eTarget: TaggedNostrEvent) {
if (opt?.canClick === false) {
return;
}
let target = e.target as HTMLElement | null;
while (target) {
if (
target.tagName === "A" ||
target.tagName === "BUTTON" ||
target.classList.contains("reaction-pill") ||
target.classList.contains("szh-menu-container")
) {
return; // is there a better way to do this?
}
target = target.parentElement;
}
e.stopPropagation();
if (props.onClick) {
props.onClick(eTarget);
@ -355,7 +364,7 @@ export function NoteInner(props: NoteProps) {
{translation()}
{pollOptions()}
{options.showReactionsLink && (
<div className="reactions-link" onClick={() => setShowReactions(true)}>
<div className="reactions-link cursor-pointer" onClick={() => setShowReactions(true)}>
<FormattedMessage {...messages.ReactionsLink} values={{ n: totalReactions }} />
</div>
)}