Event edit: automatically populate end date when setting start date.

Fixes #195.
master
Tom Hacohen 4 years ago
parent 3b50375810
commit c0d884afd7

@ -310,7 +310,13 @@ export default class EventEdit extends React.PureComponent<PropsType> {
dateOnly={this.state.allDay} dateOnly={this.state.allDay}
placeholder="Start" placeholder="Start"
value={this.state.start} value={this.state.start}
onChange={(date?: Date) => this.setState({ start: date })} onChange={(date?: Date) => {
// If end is unset, set it to start + 30 minutes
const end = this.state.end ?? (
new Date(date!.getTime() + 30 * 60 * 1000)
);
this.setState({ start: date, end });
}}
/> />
{differentTimezone && this.state.start && ( {differentTimezone && this.state.start && (
<FormHelperText>{ICAL.Time.fromJSDate(this.state.start, false).convertToZone(differentTimezone!).toJSDate().toString()}</FormHelperText> <FormHelperText>{ICAL.Time.fromJSDate(this.state.start, false).convertToZone(differentTimezone!).toJSDate().toString()}</FormHelperText>

Loading…
Cancel
Save