Skip to content

Commit

Permalink
Merge pull request #5541 from ujjwalpathaak/fix_5532/bug_in_date_pick…
Browse files Browse the repository at this point in the history
…er_component

Error handling while selecting the date and time in date_picker.jsx

Fixes #5532
  • Loading branch information
ragesoss authored Nov 30, 2023
2 parents 32ba673 + 20ae55c commit 2ee349a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions app/assets/javascripts/components/common/date_picker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,18 @@ const DatePicker = createReactClass({
},

handleHourFieldChange(e) {
if (this.state.value === '') {
this.handleDatePickerChange(new Date());
}
this.setState({
hour: e.target.value
}, this.onChangeHandler);
},

handleMinuteFieldChange(e) {
if (this.state.value === '') {
this.handleDatePickerChange(new Date());
}
this.setState({
minute: e.target.value
}, this.onChangeHandler);
Expand Down
2 changes: 1 addition & 1 deletion spec/features/campaign_overview_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ module ResetLocale
fill_in('campaign_end', with: '2016-02-10'.to_date)
find('.campaign-details .rails_editable-save').click
expect(campaign.reload.start).to eq(Time.zone.parse('2016-01-10 00:00:00'))
expect(campaign.end).to eq(Time.zone.parse('2016-02-10 23:59:59'))
expect(campaign.end).to be_within(1.second).of(Time.zone.parse('2016-02-10 23:59:59'))
click_button 'Edit'
find('.campaign-details .rails_editable-edit').click
find('#use_dates').click # uncheck
Expand Down
2 changes: 1 addition & 1 deletion spec/features/campaigns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
expect(Campaign.last.title).to eq(title)
expect(Campaign.last.description).to eq(description)
expect(Campaign.last.start).to eq(Time.zone.parse('2016-1-10 00:00:00'))
expect(Campaign.last.end).to eq(Time.zone.parse('2016-02-10 23:59:59'))
expect(Campaign.last.end).to be_within(1.second).of(Time.zone.parse('2016-02-10 23:59:59'))
end

it 'can be reached from the explore page' do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/campaign_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
campaign.end = '2016-02-10'
campaign.save
expect(campaign.start).to eq(Time.new(2016, 1, 10, 0, 0, 0, '+00:00'))
expect(campaign.end).to eq(Time.new(2016, 2, 10, 23, 59, 59, '+00:00'))
expect(campaign.end).to be_within(1.second).of(Time.new(2016, 2, 10, 23, 59, 59, '+00:00'))
end
end

Expand Down

0 comments on commit 2ee349a

Please sign in to comment.