Addressed flow issues
This commit is contained in:
@ -28,14 +28,17 @@ type DropdownMenuProps = {
|
|||||||
handleClick = (ev: SyntheticEvent) => {
|
handleClick = (ev: SyntheticEvent) => {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
const currentTarget = ev.currentTarget;
|
||||||
invariant(document.body, 'why you not here');
|
invariant(document.body, 'why you not here');
|
||||||
|
|
||||||
|
if (currentTarget instanceof HTMLDivElement) {
|
||||||
const bodyRect = document.body.getBoundingClientRect();
|
const bodyRect = document.body.getBoundingClientRect();
|
||||||
// $FlowIssue it's there
|
const targetRect = currentTarget.getBoundingClientRect();
|
||||||
const targetRect = ev.currentTarget.getBoundingClientRect();
|
|
||||||
this.open = true;
|
this.open = true;
|
||||||
this.top = targetRect.bottom - bodyRect.top;
|
this.top = targetRect.bottom - bodyRect.top;
|
||||||
this.right = bodyRect.width - targetRect.left - targetRect.width;
|
this.right = bodyRect.width - targetRect.left - targetRect.width;
|
||||||
if (this.props.onShow) this.props.onShow();
|
if (this.props.onShow) this.props.onShow();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleClose = (ev: SyntheticEvent) => {
|
handleClose = (ev: SyntheticEvent) => {
|
||||||
|
@ -9,7 +9,9 @@ const activeStyle = {
|
|||||||
fontWeight: fontWeight.semiBold,
|
fontWeight: fontWeight.semiBold,
|
||||||
};
|
};
|
||||||
|
|
||||||
// $FlowFixMe :/
|
// This is a hack for `styleComponent()` as NavLink fails to render without `to` prop
|
||||||
|
const StyleableDiv = props => <div {...props} />;
|
||||||
|
|
||||||
const styleComponent = component => styled(component)`
|
const styleComponent = component => styled(component)`
|
||||||
display: block;
|
display: block;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
@ -25,7 +27,7 @@ const styleComponent = component => styled(component)`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
function SidebarLink(props: Object) {
|
function SidebarLink(props: Object) {
|
||||||
const Component = styleComponent(props.to ? NavLink : 'div');
|
const Component = styleComponent(props.to ? NavLink : StyleableDiv);
|
||||||
return <Component exact activeStyle={activeStyle} {...props} />;
|
return <Component exact activeStyle={activeStyle} {...props} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
|||||||
@observer class CollectionMenu extends Component {
|
@observer class CollectionMenu extends Component {
|
||||||
props: {
|
props: {
|
||||||
label?: React$Element<any>,
|
label?: React$Element<any>,
|
||||||
onShow?: Function,
|
onShow?: () => void,
|
||||||
onClose?: Function,
|
onClose?: () => void,
|
||||||
history: Object,
|
history: Object,
|
||||||
ui: UiStore,
|
ui: UiStore,
|
||||||
collection: Collection,
|
collection: Collection,
|
||||||
@ -49,7 +49,6 @@ import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
|||||||
|
|
||||||
const MoreIcon = styled(Icon)`
|
const MoreIcon = styled(Icon)`
|
||||||
width: 22px;
|
width: 22px;
|
||||||
height: 22px;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default inject('ui')(CollectionMenu);
|
export default inject('ui')(CollectionMenu);
|
||||||
|
Reference in New Issue
Block a user