Skip to content

Commit d9f73ac

Browse files
author
dphaener
committed
Few new features regarding popover state
This new release allows you to fully manage the popover state externally. The global click handler was overriding this before. It also adds the ability to override the `onClick` handler on the toggle button by passing in a click handler of your own on the toggle button prop.
1 parent b391788 commit d9f73ac

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Change Log
2+
All notable changes to this project will be documented in this file.
3+
This project adheres to [Semantic Versioning](http://semver.org/).
4+
5+
## 0.2.3 (15 Jul 2016)
6+
### New Features
7+
- Adds the ability to override the `onClick` handler on the togglebutton
8+
- Adds the ability to fully manage the popover's `isOpen` state externally
9+

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "reactable-popover",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Popovers for React",
55
"main": "./lib/popover.js",
66
"scripts": {

src/popover.jsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ export default class Popover extends React.Component {
3838
}
3939

4040
globalClick = () => {
41-
if(this.state.isOpen == true) this.setState({isOpen: false})
41+
if (this.props.isOpen) {
42+
if (this.props.isOpen != this.state.isOpen) this.setState({ isOpen: this.props.isOpen });
43+
} else {
44+
if (this.state.isOpen == true) this.setState({ isOpen: false });
45+
}
4246
}
4347

4448
handleClick = (ev) => {
@@ -125,10 +129,10 @@ export default class Popover extends React.Component {
125129
}
126130

127131
render() {
128-
if(this.props.toggleButton){
132+
if (this.props.toggleButton){
129133
var toggleButton = React.cloneElement(this.props.toggleButton, {
130134
ref: 'toggleButton',
131-
onClick: this.toggleButton
135+
onClick: this.props.toggleButton.props.onClick || this.toggleButton
132136
})
133137
}
134138
else {

0 commit comments

Comments
 (0)