Datepicker inside a modal
See original GitHub issueHi, 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:
- Created 7 years ago
- Reactions:4
- Comments:16
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am also having this issue on the time picker portion of this.
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 istrue
, the component will rune.stopPropagation()
on all mouse clicks inside the calendar.@martijnrusschen would you consider a PR with the proposed change?