fix: Clicking the share link from a context menu propagates the click onto the container (#1643)
closes #1642
This commit is contained in:
@@ -9,6 +9,7 @@ import Document from "models/Document";
|
|||||||
import Badge from "components/Badge";
|
import Badge from "components/Badge";
|
||||||
import Button from "components/Button";
|
import Button from "components/Button";
|
||||||
import DocumentMeta from "components/DocumentMeta";
|
import DocumentMeta from "components/DocumentMeta";
|
||||||
|
import EventBoundary from "components/EventBoundary";
|
||||||
import Flex from "components/Flex";
|
import Flex from "components/Flex";
|
||||||
import Highlight from "components/Highlight";
|
import Highlight from "components/Highlight";
|
||||||
import Tooltip from "components/Tooltip";
|
import Tooltip from "components/Tooltip";
|
||||||
@@ -123,7 +124,9 @@ class DocumentPreview extends React.Component<Props> {
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<DocumentMenu document={document} showPin={showPin} />
|
<EventBoundary>
|
||||||
|
<DocumentMenu document={document} showPin={showPin} />
|
||||||
|
</EventBoundary>
|
||||||
</SecondaryActions>
|
</SecondaryActions>
|
||||||
</Heading>
|
</Heading>
|
||||||
|
|
||||||
|
|||||||
16
app/components/EventBoundary.js
Normal file
16
app/components/EventBoundary.js
Normal 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>;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user