Skip to content
This repository was archived by the owner on Nov 16, 2018. It is now read-only.

Commit b06ec63

Browse files
committed
Merge pull request #153 from paulcurley/zindex-config
Override default zIndex on overlay
2 parents c2c277c + 7cdf54e commit b06ec63

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/DateTimeField.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default class DateTimeField extends Component {
1313
daysOfWeekDisabled: [],
1414
size: Constants.SIZE_MEDIUM,
1515
mode: Constants.MODE_DATETIME,
16+
zIndex: 999,
1617
onChange: (x) => {
1718
console.log(x);
1819
}
@@ -46,6 +47,7 @@ export default class DateTimeField extends Component {
4647
direction: PropTypes.string,
4748
showToday: PropTypes.bool,
4849
viewMode: PropTypes.string,
50+
zIndex: PropTypes.number,
4951
size: PropTypes.oneOf([Constants.SIZE_SMALL, Constants.SIZE_MEDIUM, Constants.SIZE_LARGE]),
5052
daysOfWeekDisabled: PropTypes.arrayOf(PropTypes.number)
5153
}
@@ -327,10 +329,10 @@ export default class DateTimeField extends Component {
327329
bottom: 0,
328330
left: 0,
329331
right: 0,
330-
zIndex: "999"
332+
zIndex: `${this.props.zIndex}`
331333
};
332334
if (this.state.showPicker) {
333-
return (<div onClick={this.closePicker} style={styles} />);
335+
return (<div className='bootstrap-datetimepicker-overlay' onClick={this.closePicker} style={styles} />);
334336
} else {
335337
return <span />;
336338
}

src/__tests__/DateTimeField-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react";
2+
import ReactDOM from "react-dom";
23
import TestUtils from "react-addons-test-utils";
34

45
jest.dontMock("moment");
@@ -19,6 +20,14 @@ describe("DateTimeField", function() {
1920
expect(input.value).toBe("06/05/90 7:30 AM");
2021
});
2122

23+
it("allows a custom zIndex to be applied to overlay", function() {
24+
const component = TestUtils.renderIntoDocument(<DateTimeField zIndex={1234} />);
25+
const input = TestUtils.findRenderedDOMComponentWithClass(component, "input-group-addon");
26+
TestUtils.Simulate.click(input);
27+
const overlay = TestUtils.findRenderedDOMComponentWithClass(component, "bootstrap-datetimepicker-overlay");
28+
expect(ReactDOM.findDOMNode(overlay).style.zIndex).toBe('1234');
29+
});
30+
2231
});
2332

2433
describe("When changing props", function() {

0 commit comments

Comments
 (0)