diff --git a/src/components/ProjectStatus/ProjectStatus.scss b/src/components/ProjectStatus/ProjectStatus.scss index befcfc794..d401b05b9 100644 --- a/src/components/ProjectStatus/ProjectStatus.scss +++ b/src/components/ProjectStatus/ProjectStatus.scss @@ -178,6 +178,11 @@ $status-height: 20px; z-index: 2; transition: 250ms all; + &.dropdown-up { + top: auto; + bottom: 0; + } + .status-header { @include roboto-medium; font-size: $tc-label-md; diff --git a/src/components/ProjectStatus/editableProjectStatus.js b/src/components/ProjectStatus/editableProjectStatus.js index dd07c888c..5fe45d40c 100644 --- a/src/components/ProjectStatus/editableProjectStatus.js +++ b/src/components/ProjectStatus/editableProjectStatus.js @@ -11,6 +11,68 @@ import { PROJECT_STATUS_CANCELLED } from '../../config/constants' +const hocStatusDropdown = (CompositeComponent) => { + class StatusDropdown extends Component { + shouldDropdownUp() { + if (this.refs.dropdown) { + const bounds = this.refs.dropdown.getBoundingClientRect() + const windowHeight = window.innerHeight + + return bounds.top > windowHeight / 2 + } + + return false + } + + render() { + const { canEdit, isOpen, handleClick, onItemSelect, showText, withoutLabel, unifiedHeader, status } = this.props + const selected = PROJECT_STATUS.filter((opt) => opt.value === status)[0] + + this.shouldDropdownUp() + return ( +
+
+ + { canEdit && } +
+ { isOpen && canEdit && +
+
Project Status
+ +
+ } +
+ ) + } + } + + return StatusDropdown +} + const editableProjectStatus = (CompositeComponent) => class extends Component { constructor(props) { super(props) @@ -56,50 +118,10 @@ const editableProjectStatus = (CompositeComponent) => class extends Component { this.setState({ statusChangeReason : _.get(reason, 'value') }) } - renderDropdown(props) { - const { canEdit, isOpen, handleClick, onItemSelect, showText, withoutLabel, unifiedHeader, status } = props - const selected = PROJECT_STATUS.filter((opt) => opt.value === status)[0] - return ( -
-
- - { canEdit && } -
- { isOpen && canEdit && -
-
Project Status
- -
- } -
- ) - } - render() { const { showStatusChangeDialog, newStatus, statusChangeReason } = this.state const { canEdit } = this.props - const ProjectStatusDropdown = canEdit ? enhanceDropdown(this.renderDropdown) : this.renderDropdown + const ProjectStatusDropdown = canEdit ? enhanceDropdown(hocStatusDropdown(CompositeComponent)) : hocStatusDropdown(CompositeComponent) return (