Skip to content

Commit d9e7621

Browse files
committed
fix(TetherContent): Fixes className prop typo, removes arrow & position relative hack
1 parent bd851b6 commit d9e7621

2 files changed

Lines changed: 13 additions & 21 deletions

File tree

src/TetherContent.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import React, { PropTypes } from 'react';
22
import ReactDOM from 'react-dom';
33
import isFunction from 'lodash.isfunction';
44
import Tether from 'tether';
5-
import { mapToCssModules } from './utils';
65

76
const propTypes = {
87
children: PropTypes.node.isRequired,
8+
className: PropTypes.string,
99
arrow: PropTypes.string,
1010
disabled: PropTypes.bool,
1111
isOpen: PropTypes.bool.isRequired,
@@ -101,15 +101,9 @@ class TetherContent extends React.Component {
101101
document.addEventListener('click', this.handleDocumentClick, true);
102102

103103
this._element = document.createElement('div');
104+
this._element.className = this.props.className;
104105
document.body.appendChild(this._element);
105106
this.renderIntoSubtree();
106-
107-
if (this.props.arrow) {
108-
const arrow = document.createElement('div');
109-
arrow.className = mapToCssModules(this.props.arrow + '-arrow', this.props.cssModule);
110-
this._element.appendChild(arrow);
111-
}
112-
113107
this._tether = new Tether(this.getTetherConfig());
114108
this.props.tetherRef(this._tether);
115109
this._tether.position();
@@ -136,9 +130,7 @@ class TetherContent extends React.Component {
136130
const { children, style } = this.props;
137131
return React.cloneElement(
138132
children,
139-
{
140-
style: { position: 'relative', ...style }
141-
}
133+
{ style }
142134
);
143135
}
144136

src/__tests__/TetherContent.spec.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ describe('TetherContent', () => {
2424
expect(instance._element).toBe(undefined);
2525
});
2626

27+
it('should renderChildren with className', () => {
28+
state = true;
29+
spyOn(TetherContent.prototype, 'componentDidMount').and.callThrough();
30+
spyOn(TetherContent.prototype, 'renderChildren').and.callThrough();
31+
const wrapper = mount(<TetherContent className="foo" tether={tetherConfig} isOpen={state} toggle={toggle}><p>Content</p></TetherContent>);
32+
const instance = wrapper.instance();
33+
34+
expect(instance._element.className.indexOf('foo') > -1).toBe(true);
35+
});
36+
2737
it('should renderChildren when isOpen is true', () => {
2838
state = true;
2939
spyOn(TetherContent.prototype, 'componentDidMount').and.callThrough();
@@ -37,16 +47,6 @@ describe('TetherContent', () => {
3747
expect(instance._element.className.indexOf('tether') > -1).toBe(true);
3848
});
3949

40-
it('should render an arrow dom node when prop is true', () => {
41-
state = true;
42-
const wrapper = mount(<TetherContent tether={tetherConfig} isOpen={state} arrow="tooltip" toggle={toggle}><p>Content</p></TetherContent>);
43-
const instance = wrapper.instance();
44-
45-
expect(instance._element.textContent).toBe('Content');
46-
expect(instance._tether.enabled).toBe(true);
47-
expect(instance._element.innerHTML.indexOf('<div class="tooltip-arrow"></div>') > -1).toBe(true);
48-
});
49-
5050
it('should not call props.toggle when disabled ', () => {
5151
state = true;
5252
let props = jasmine.createSpyObj('props', ['toggle']);

0 commit comments

Comments
 (0)