Skip to content

Commit 6fbbc8e

Browse files
committed
Apply zIndex prop and overlay className
1 parent c2c277c commit 6fbbc8e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/DateTimeField.js

Lines changed: 5 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
}
@@ -321,16 +323,17 @@ export default class DateTimeField extends Component {
321323
}
322324

323325
renderOverlay = () => {
326+
324327
const styles = {
325328
position: "fixed",
326329
top: 0,
327330
bottom: 0,
328331
left: 0,
329332
right: 0,
330-
zIndex: "999"
333+
zIndex: `${this.props.zIndex}`
331334
};
332335
if (this.state.showPicker) {
333-
return (<div onClick={this.closePicker} style={styles} />);
336+
return (<div className='bootstrap-datetimepicker-overlay' onClick={this.closePicker} style={styles} />);
334337
} else {
335338
return <span />;
336339
}

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)