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

Use type definition for the controller's element.

Dombi Attilac7fa8b3f582b
diff --git a/frontend/src/stimulus/controllers/form-preview.controller.ts b/frontend/src/stimulus/controllers/form-preview.controller.ts
index ce6560fc894..cd22b91e15b 100644
--- a/frontend/src/stimulus/controllers/form-preview.controller.ts
+++ b/frontend/src/stimulus/controllers/form-preview.controller.ts
@@ -28,27 +28,19 @@
* ++
*/
-import { ApplicationController } from 'stimulus-use';
+import { Controller } from '@hotwired/stimulus';
-export default class FormPreviewController extends ApplicationController {
+export default class FormPreviewController extends Controller<HTMLFormElement> {
static values = { url: String };
- declare readonly formTarget:HTMLFormElement;
declare urlValue:string;
- connect() {
- // Ensure this.element is a form element
- if (!(this.element instanceof HTMLFormElement)) {
- throw new Error('The controller must be bound to a <form> element');
- }
- }
-
async submit():Promise<void> {
if (!this.urlValue) {
return;
}
- const form = this.element as HTMLFormElement;
+ const form = this.element;
form.action = this.urlValue;
form.requestSubmit();