profileOverlay: fix dismiss clobbering dropdown

This commit is contained in:
Matilde Park 2021-01-28 19:04:41 -05:00
parent 53d416cf16
commit 7911821c7a

View File

@ -26,11 +26,13 @@ type ProfileOverlayProps = ColProps & {
class ProfileOverlay extends PureComponent<ProfileOverlayProps, {}> { class ProfileOverlay extends PureComponent<ProfileOverlayProps, {}> {
public popoverRef: React.Ref<typeof Col>; public popoverRef: React.Ref<typeof Col>;
public dropdownRef: React.Ref<typeof Col>;
constructor(props) { constructor(props) {
super(props); super(props);
this.popoverRef = React.createRef(); this.popoverRef = React.createRef();
this.dropdownRef = React.createRef();
this.onDocumentClick = this.onDocumentClick.bind(this); this.onDocumentClick = this.onDocumentClick.bind(this);
} }
@ -45,9 +47,9 @@ class ProfileOverlay extends PureComponent<ProfileOverlayProps, {}> {
} }
onDocumentClick(event) { onDocumentClick(event) {
const { popoverRef } = this; const { popoverRef, dropdownRef } = this;
// Do nothing if clicking ref's element or descendent elements // Do nothing if clicking ref's element or descendent elements
if (!popoverRef.current || popoverRef.current.contains(event.target)) { if (!popoverRef.current || dropdownRef.current.contains(event.target) || popoverRef.current.contains(event.target)) {
return; return;
} }
@ -129,13 +131,14 @@ class ProfileOverlay extends PureComponent<ProfileOverlayProps, {}> {
border={1} border={1}
borderRadius={2} borderRadius={2}
borderColor="lightGray" borderColor="lightGray"
ref={this.dropdownRef}
boxShadow="0px 0px 0px 3px"> boxShadow="0px 0px 0px 3px">
<Row <Row
p={1} p={1}
color='black' color='black'
cursor='pointer' cursor='pointer'
fontSize={0} fontSize={0}
onClick={() => history.push('/~profile/' + window.ship)}> onClick={() => history.push('/~profile/~' + window.ship)}>
View Profile View Profile
</Row> </Row>
{(!isOwn) && ( {(!isOwn) && (