OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix datepicker cloning
Oliver Günther0b2938702a92
diff --git a/frontend/src/stimulus/controllers/dynamic/subform.controller.ts b/frontend/src/stimulus/controllers/dynamic/subform.controller.tsindex 342df55f6dc..455b7e5677a 100644--- a/frontend/src/stimulus/controllers/dynamic/subform.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/subform.controller.ts@@ -38,12 +38,12 @@ export default class SubformController extends Controller {declare readonly tableTarget:HTMLTableElement;- private rowTemplate:HTMLElement;+ private rowTemplate:string;connect() {// We can't use a target as we duplicate the "template" without much cleaning upconst item = this.element.querySelector('[data-row-target]') as HTMLElement;- this.rowTemplate = item;+ this.rowTemplate = item.outerHTML;item.remove();}@@ -54,13 +54,16 @@ export default class SubformController extends Controller {addRow() {const index = this.itemCount;- const newRow = this.rowTemplate.cloneNode(true) as HTMLElement;- this.tableTarget.appendChild(newRow);- newRow.style.removeProperty('display');- newRow.outerHTML = newRow.outerHTML.replace(/INDEX/g, index.toString());+ const newRow = this.rowTemplate.replace(/INDEX/g, index.toString());+ this.tableTarget.insertAdjacentHTML('beforeend', newRow);++ const last = this.tableTarget.lastElementChild as HTMLElement;+ last.style.removeProperty('display'); // Show the row// Autofocus- setTimeout(() => newRow.querySelector<HTMLElement>('input')?.focus(), 10);+ setTimeout(() => {+ last.querySelector<HTMLElement>('input')?.focus();+ }, 50);}get itemCount():number {diff --git a/modules/costs/spec/features/members_hourly_rates_spec.rb b/modules/costs/spec/features/members_hourly_rates_spec.rbindex 2d40a14b060..485bc20e58f 100644--- a/modules/costs/spec/features/members_hourly_rates_spec.rb+++ b/modules/costs/spec/features/members_hourly_rates_spec.rb@@ -57,6 +57,7 @@ RSpec.describe "hourly rates on a member", :js doclick_link_or_button "Add rate"datepicker = Components::BasicDatepicker.new+ datepicker.expect_visibledatepicker.set_date(date.strftime("%Y-%m-%d"))within "tr[id^='user_new_rate_attributes_']" do@@ -68,6 +69,7 @@ RSpec.describe "hourly rates on a member", :js doinput = find("table.rates .date input[data-value='#{from.strftime('%Y-%m-%d')}']")input.clickdatepicker = Components::BasicDatepicker.new+ datepicker.expect_visibledatepicker.set_date(to.strftime("%Y-%m-%d"))end