fix: Clicking the share link from a context menu propagates the click onto the container (#1643)

closes #1642
This commit is contained in:
Tom Moor
2020-11-11 09:02:02 -08:00
committed by GitHub
parent 26e6db1afd
commit 80d74c9334
2 changed files with 20 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import Document from "models/Document";
import Badge from "components/Badge";
import Button from "components/Button";
import DocumentMeta from "components/DocumentMeta";
import EventBoundary from "components/EventBoundary";
import Flex from "components/Flex";
import Highlight from "components/Highlight";
import Tooltip from "components/Tooltip";
@@ -123,7 +124,9 @@ class DocumentPreview extends React.Component<Props> {
</Button>
)}
&nbsp;
<DocumentMenu document={document} showPin={showPin} />
<EventBoundary>
<DocumentMenu document={document} showPin={showPin} />
</EventBoundary>
</SecondaryActions>
</Heading>

View File

@@ -0,0 +1,16 @@
// @flow
import * as React from "react";
type Props = {
children: React.Node,
};
export default function EventBoundary({ children }: Props) {
const handleClick = React.useCallback((event: SyntheticEvent<>) => {
event.preventDefault();
event.stopPropagation();
}, []);
return <span onClick={handleClick}>{children}</span>;
}