Skip to content

Commit

Permalink
[#60578] Unable to use the date picker for stages
Browse files Browse the repository at this point in the history
  • Loading branch information
dombesz committed Jan 15, 2025
1 parent c7fa8b3 commit f2fd1fa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/forms/projects/life_cycles/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def base_input_attributes
leading_visual: { icon: :calendar },
datepicker_options: {
inDialog: ProjectLifeCycles::Sections::EditDialogComponent::DIALOG_ID,
data: { action: "change->overview--project-life-cycles-form#handleChange" }
data: { action: "change->overview--project-life-cycles-form#previewForm" }
},
wrapper_data_attributes: {
"qa-field-name": qa_field_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import { Controller } from '@hotwired/stimulus';

export default class ProjectLifeCyclesFormController extends Controller {
handleChange(event:Event) {
previewForm(event:Event) {
const target = event.target as HTMLElement;
if (this.datePickerVisible(target)) {
return; // flatpickr is still open, do not submit yet.
Expand All @@ -41,9 +41,6 @@ export default class ProjectLifeCyclesFormController extends Controller {
}

datePickerVisible(element:HTMLElement) {
const nextElement = element.nextElementSibling;
return nextElement
&& nextElement.classList.contains('flatpickr-calendar')
&& nextElement.classList.contains('open');
return element.classList.contains('active');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@
# Retrying due to a race condition between filling the input vs submitting the form preview.
original_dates = [life_cycle_initiating.start_date, life_cycle_initiating.end_date]
dialog.set_date_for(life_cycle_initiating, value: original_dates)

page.driver.clear_network_traffic
dialog.set_date_for(life_cycle_initiating, value: initiating_dates)

dialog.expect_caption(life_cycle_initiating, text: "Duration: 8 working days")
# Ensure that only 1 ajax request is triggered after setting the date range.
expect(page.driver.browser.network.traffic.size).to eq(1)
end

ready_for_planning_date = start_date + 1.day
Expand Down

0 comments on commit f2fd1fa

Please sign in to comment.