question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Datepicker inside a modal

See original GitHub issue

Hi, I have a datepicker inside a modal. Whenever I clicked on the date, the modal got closed too. Is there a way to avoid this? My code looks like this

import React from 'react';
import moment from 'moment';
import { change } from 'redux-form';
import DatePicker from 'react-datepicker';

class ReservationDetailsCheckinContainer extends React.Component {
  constructor(props) {
    super(props);
  }

  handleInputChange(e) {
    console.log(e);
  }

  render() {
    return (
      <div className="pull-left" style={{
        width: '65%'
      }}>
        <label>
          Check-in Date
        </label>
        <div>
          <DatePicker selected={this.state.startDate} onChange={this.handleInputChange}/>
        </div>
      </div>
    );
  }
}

export default ReservationDetailsCheckinContainer;

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:16

github_iconTop GitHub Comments

4reactions
ishakecommented, Feb 7, 2018

I am also having this issue on the time picker portion of this.

4reactions
amakhrovcommented, Jun 8, 2017

Actually, passing the event into onChange wouldn’t solve the issue completely. A user can click on the calendar without selecting a date (e.g. navigating between months). And in the scenario above it will as well close the modal.

An alternative suggestion is to introduce a new property: stopPropagationOnClick: PropTypes.bool. If this property is true, the component will run e.stopPropagation() on all mouse clicks inside the calendar.

@martijnrusschen would you consider a PR with the proposed change?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap datepicker in modal not working - Stack Overflow
The datepicker is hiding behind the modal. Set datepicker's z-index above the modal's which is 1050 . Additionally wrap your datepicker code ...
Read more >
Bootstrap Datepicker in Modal Popup Window - CodeHim
The plugin has multi options, multi functions and multi languages to pick current, selected or filtered date.
Read more >
How to Use Datetimepicker in Bootstrap Modal Popup?
Transcript · Input date and time in HTML and Javascript || (flatpickr.js) · How to create a modal popup box with Bootstrap 5...
Read more >
Bootstrap datepicker in modal - CodePen
Adding Classes. In CodePen, whatever you write in the HTML editor is what goes within the <body> tags in a basic HTML5 template....
Read more >
Datepicker not working inside of Modal Window #2736 - GitHub
Hello All,. I am trying to manage ngx-date picker in modal popup at the time of scrolling it's not move with date text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found