Search code examples
reactjsreact-bootstrapreact-datepicker

React-Datepicker layout broken inside a Bootstrap-React Modal (calendar truncated)


I'm using React Datepicker inside a Bootstrap React Modal dialog.

Getting the following layout issue when clicking the text box to open the calendar:

enter image description here

The basic code is this:

                      <Modal show={this.state.isDialogOpenB} onHide={this.handleDialogCloseB}>
                        <Modal.Header closeButton>
                          <Modal.Title>Editing UserID: {this.state.activeItemIdB} Username: {this.state.activeItemNameB}</Modal.Title>
                        </Modal.Header>
                        <Modal.Body>
                            <div class="custom-control custom-checkbox">
                                <input type="checkbox" class="custom-control-input" id="bChkboxLocked"></input>
                                <label class="custom-control-label" htmlFor="bChkboxLocked">Locked</label>
                            </div>
                            <div>
                                <DatePicker dateFormat="MM/dd/yyyy" selected={this.state.testDate} onChange={this.handleDatePickerChangeB} />
                            </div>
                        </Modal.Body>
                        <Modal.Footer>
                          <Button variant="secondary" onClick={this.handleDialogCloseB}>
                            Close
                          </Button>
                        </Modal.Footer>
                      </Modal>                  

Solution

  • I didn't have a lot of time to debug this, but I found a better datepicker that doesn't depend on its outer DIV: React Day-Picker :

    enter image description here