goToEvent target handling
Some checks failed
continuous-integration/drone/pr Build is failing

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 <Menu
menuButton={ menuButton={
<div className="reaction-pill"> <div className="reaction-pill cursor-pointer">
<Icon name="dots" size={15} /> <Icon name="dots" size={15} />
</div> </div>
} }

View File

@ -316,7 +316,7 @@ const AsyncFooterIcon = forwardRef((props: AsyncIconProps & { value: number }, r
const mergedProps = { const mergedProps = {
...props, ...props,
iconSize: 18, 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 ( return (

View File

@ -177,15 +177,24 @@ export function NoteInner(props: NoteProps) {
return innerContent; return innerContent;
}; };
function goToEvent( function goToEvent(e: React.MouseEvent, eTarget: TaggedNostrEvent) {
e: React.MouseEvent, if (opt?.canClick === false) {
eTarget: TaggedNostrEvent,
isTargetAllowed: boolean = e.target === e.currentTarget,
) {
if (!isTargetAllowed || opt?.canClick === false) {
return; 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(); e.stopPropagation();
if (props.onClick) { if (props.onClick) {
props.onClick(eTarget); props.onClick(eTarget);
@ -355,7 +364,7 @@ export function NoteInner(props: NoteProps) {
{translation()} {translation()}
{pollOptions()} {pollOptions()}
{options.showReactionsLink && ( {options.showReactionsLink && (
<div className="reactions-link" onClick={() => setShowReactions(true)}> <div className="reactions-link cursor-pointer" onClick={() => setShowReactions(true)}>
<FormattedMessage {...messages.ReactionsLink} values={{ n: totalReactions }} /> <FormattedMessage {...messages.ReactionsLink} values={{ n: totalReactions }} />
</div> </div>
)} )}