Skip to content

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

Close modals when turbo navigates

Oliver Günther5a31de47820d
diff --git a/frontend/src/app/core/augmenting/openproject-augmenting.module.ts b/frontend/src/app/core/augmenting/openproject-augmenting.module.ts
index 395ca9f6fc0..31e4c868487 100644
--- a/frontend/src/app/core/augmenting/openproject-augmenting.module.ts
+++ b/frontend/src/app/core/augmenting/openproject-augmenting.module.ts
@@ -37,5 +37,9 @@ export class OpenprojectAugmentingModule {
constructor(modalWrapper:OpModalWrapperAugmentService) {
// Setup augmenting services
modalWrapper.setupListener();
+
+ document.addEventListener('turbo:load', () => {
+ modalWrapper.setupListener();
+ });
}
}
diff --git a/frontend/src/app/shared/components/modal/modal-wrapper-augment.service.ts b/frontend/src/app/shared/components/modal/modal-wrapper-augment.service.ts
index 5c5a0a13869..d4307e3ab16 100644
--- a/frontend/src/app/shared/components/modal/modal-wrapper-augment.service.ts
+++ b/frontend/src/app/shared/components/modal/modal-wrapper-augment.service.ts
@@ -43,7 +43,9 @@ export class OpModalWrapperAugmentService {
@Inject(DOCUMENT) protected documentElement:Document,
protected injector:Injector,
protected opModalService:OpModalService,
- ) {}
+ ) {
+ documentElement.addEventListener('turbo:before-render', () => opModalService.close());
+ }
/**
* Create initial listeners for Rails-rendered modals
diff --git a/modules/two_factor_authentication/spec/features/account_activation_spec.rb b/modules/two_factor_authentication/spec/features/account_activation_spec.rb
index 78c2a665a0a..3c5ac03cf98 100644
--- a/modules/two_factor_authentication/spec/features/account_activation_spec.rb
+++ b/modules/two_factor_authentication/spec/features/account_activation_spec.rb
@@ -1,7 +1,9 @@
require_relative "../spec_helper"
require_relative "shared_2fa_examples"
-RSpec.describe "activating an invited account", :js,
+RSpec.describe "activating an invited account",
+ :js,
+ :with_cuprite,
with_settings: {
plugin_openproject_two_factor_authentication: { "active_strategies" => [:developer] }
} do
@@ -49,12 +51,11 @@ RSpec.describe "activating an invited account", :js,
# rubocop:enable RSpec/AnyInstance
activate!
-
expect_flash(message: "Developer strategy generated the following one-time password:")
- SeleniumHubWaiter.wait
fill_in I18n.t(:field_otp), with: sms_token
click_button I18n.t(:button_login)
+ wait_for_network_idle
visit my_account_path
expect(page).to have_css(".form--field-container", text: user.login)
diff --git a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb
index 3042abf82fa..2d0a94a2465 100644
--- a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb
+++ b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb
@@ -44,6 +44,7 @@ RSpec.shared_examples "create enforced sms device" do
SeleniumHubWaiter.wait
fill_in "device_phone_number", with: "invalid"
click_on "Continue"
+ wait_for_network_idle
# Expect error on invalid phone
expect_flash(type: :error, message: "Phone number must be of format +XX XXXXXXXXX")
@@ -51,12 +52,12 @@ RSpec.shared_examples "create enforced sms device" do
SeleniumHubWaiter.wait
fill_in "device_phone_number", with: "+49 123456789"
click_on "Continue"
+ wait_for_network_idle
# Confirm page
expect(page).to have_css("h2", text: I18n.t("two_factor_authentication.devices.confirm_device"))
expect(page).to have_css("input#otp")
- SeleniumHubWaiter.wait
# Fill in wrong token
fill_in "otp", with: "whatever"