diff --git a/bigbluebutton-html5/imports/ui/components/dropdown/component.jsx b/bigbluebutton-html5/imports/ui/components/dropdown/component.jsx index 4183ae38cf..23bf500e1c 100644 --- a/bigbluebutton-html5/imports/ui/components/dropdown/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/dropdown/component.jsx @@ -1,6 +1,8 @@ -import React, { Component } from 'react'; +import React, { Component, Fragment } from 'react'; import PropTypes from 'prop-types'; import { findDOMNode } from 'react-dom'; +import { isMobile } from 'react-device-detect'; +import TetherComponent from 'react-tether'; import cx from 'classnames'; import { defineMessages, injectIntl, intlShape } from 'react-intl'; import Button from '/imports/ui/components/button/component'; @@ -16,7 +18,7 @@ const intlMessages = defineMessages({ }, }); -const noop = () => {}; +const noop = () => { }; const propTypes = { /** @@ -51,6 +53,7 @@ const propTypes = { onShow: PropTypes.func, autoFocus: PropTypes.bool, intl: intlShape.isRequired, + tethered: PropTypes.bool, }; const defaultProps = { @@ -60,6 +63,16 @@ const defaultProps = { autoFocus: false, isOpen: false, keepOpen: null, + getContent: () => {}, +}; + +const attachments = { + 'right-bottom': 'bottom left', + 'right-top': 'bottom left', +}; +const targetAttachments = { + 'right-bottom': 'bottom right', + 'right-top': 'top right', }; class Dropdown extends Component { @@ -162,10 +175,24 @@ class Dropdown extends Component { className, intl, keepOpen, + tethered, + placement, + getContent, ...otherProps } = this.props; const { isOpen } = this.state; + + const placements = placement && placement.replace(' ', '-'); + const test = isMobile ? { + width: '100%', + height: '100%', + transform: 'translateY(0)', + } : { + width: '', + height: '', + transform: '', + }; let trigger = children.find(x => x.type === DropdownTrigger); let content = children.find(x => x.type === DropdownContent); @@ -176,15 +203,20 @@ class Dropdown extends Component { dropdownToggle: this.handleToggle, dropdownShow: this.handleShow, dropdownHide: this.handleHide, + keepOpen, }); content = React.cloneElement(content, { - ref: (ref) => { this.content = ref; }, + ref: (ref) => { + getContent(ref); + this.content = ref; + }, 'aria-expanded': isOpen, dropdownIsOpen: isOpen, dropdownToggle: this.handleToggle, dropdownShow: this.handleShow, dropdownHide: this.handleHide, + keepOpen, }); const showCloseBtn = (isOpen && keepOpen) || (isOpen && keepOpen === null); @@ -199,18 +231,67 @@ class Dropdown extends Component { ref={(node) => { this.dropdown = node; }} tabIndex={-1} > - {trigger} - {content} - {showCloseBtn - ? ( -