File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ export default class PopoversPage extends React.Component {
3434 // target div ID, popover is attached to this element
3535 tether: PropTypes.object,
3636 // optionally overide tether config http://tether.io/#options
37+ tetherRef: PropType.function,
38+ // function which is passed a reference to the instance of tether for manually \`position()\`ing
3739 placement: PropTypes.oneOf([
3840 'top',
3941 'bottom',
Original file line number Diff line number Diff line change 11import React , { PropTypes } from 'react' ;
2+ import classNames from 'classnames' ;
3+ import omit from 'lodash.omit' ;
24import TetherContent from './TetherContent' ;
35import { getTetherAttachments , tetherAttachements } from './utils' ;
46
@@ -7,7 +9,8 @@ const propTypes = {
79 target : PropTypes . string . isRequired ,
810 isOpen : PropTypes . bool ,
911 tether : PropTypes . object ,
10- children : PropTypes . node ,
12+ tetherRef : PropTypes . func ,
13+ className : PropTypes . string ,
1114 toggle : PropTypes . func
1215} ;
1316
@@ -50,16 +53,22 @@ class Popover extends React.Component {
5053
5154 let tetherConfig = this . getTetherConfig ( ) ;
5255
56+ const classes = classNames (
57+ 'popover-inner' ,
58+ this . props . className
59+ ) ;
60+
61+ const attributes = omit ( this . props , Object . keys ( propTypes ) ) ;
62+
5363 return (
5464 < TetherContent
5565 arrow = "popover"
5666 tether = { tetherConfig }
67+ tetherRef = { this . props . tetherRef }
5768 isOpen = { this . props . isOpen }
5869 toggle = { this . props . toggle }
5970 >
60- < div className = "popover-inner" >
61- { this . props . children }
62- </ div >
71+ < div { ...attributes } className = { classes } />
6372 </ TetherContent >
6473 ) ;
6574 }
Original file line number Diff line number Diff line change @@ -134,4 +134,17 @@ describe('Popover', () => {
134134
135135 wrapper . unmount ( ) ;
136136 } ) ;
137+
138+ it ( 'should allow custom classes to be added to the popover-inner' , ( ) => {
139+ const wrapper = mount (
140+ < Popover isOpen placement = { placement } target = "popover-target" className = "popover-special" >
141+ < PopoverTitle > Title</ PopoverTitle >
142+ < PopoverContent > Content</ PopoverContent >
143+ </ Popover >
144+ ) ;
145+
146+ expect ( document . getElementsByClassName ( 'popover-inner' ) [ 0 ] . className . indexOf ( 'popover-special' ) > - 1 ) . toBe ( true ) ;
147+
148+ wrapper . unmount ( ) ;
149+ } ) ;
137150} ) ;
You can’t perform that action at this time.
0 commit comments