Skip to content

Commit

Permalink
Add manual state for popover
Browse files Browse the repository at this point in the history
The manual state is used in the docs, but is not implemented. Using this popover will properly listen to setting the visiblity state on mount
  • Loading branch information
Adnan Oner authored and hazel54 committed Mar 1, 2019
1 parent fe00875 commit 8e304ad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/popover/Popover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export default class Popover extends Component {

popper.addEventListener('mouseenter', this.handleMouseEnter.bind(this));
popper.addEventListener('mouseleave', this.handleMouseLeave.bind(this));
} else if (trigger === 'manual') {
this.setState({ showPopper: this.props.visible });
} else {
if (this.reference.nodeName === 'INPUT' || this.reference.nodeName === 'TEXTAREA') {
this.reference.addEventListener('focus', () => { this.setState({ showPopper: true })});
Expand Down Expand Up @@ -139,7 +141,7 @@ export default class Popover extends Component {
Popover.propTypes = {
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
placement: PropTypes.oneOf(['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end']),
trigger: PropTypes.oneOf(['click', 'focus', 'hover']),
trigger: PropTypes.oneOf(['click', 'focus', 'hover', 'manual']),
title: PropTypes.string,
content: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
popperClass: PropTypes.string,
Expand Down

0 comments on commit 8e304ad

Please sign in to comment.