From 44714ee0300b20154759b7c1cc107fb83734274c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 8 Oct 2024 13:56:40 +0200 Subject: [PATCH] Remove focusout submits the field (#16910) * Remove focusout submits the field https://community.openproject.org/work_packages/58286 * Adapt spec now it's no longer submitting --- .../work-package-comment-field-handler.ts | 7 +------ .../fields/edit/editing-portal/edit-field-handler.ts | 5 ----- .../edit/field-handler/hal-resource-edit-field-handler.ts | 8 -------- .../fields/edit/field-types/float-edit-field.component.ts | 1 - .../integer-edit-field/integer-edit-field.component.ts | 1 - .../edit/field-types/text-edit-field.component.html | 1 - .../widgets/custom-text/custom-text-edit-field.service.ts | 4 ---- spec/features/work_packages/edit_work_package_spec.rb | 7 +++---- 8 files changed, 4 insertions(+), 30 deletions(-) diff --git a/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment-field-handler.ts b/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment-field-handler.ts index cb15ffcec994..c5ec779f6549 100644 --- a/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment-field-handler.ts +++ b/frontend/src/app/features/work-packages/components/work-package-comment/work-package-comment-field-handler.ts @@ -1,7 +1,5 @@ import { EditFieldHandler } from 'core-app/shared/components/fields/edit/editing-portal/edit-field-handler'; -import { - ElementRef, Injector, OnInit, Directive, -} from '@angular/core'; +import { Directive, ElementRef, Injector, OnInit } from '@angular/core'; import { IFieldSchema } from 'core-app/shared/components/fields/field.base'; import { Subject } from 'rxjs'; import { WorkPackageChangeset } from 'core-app/features/work-packages/components/wp-edit/work-package-changeset'; @@ -86,9 +84,6 @@ export abstract class WorkPackageCommentFieldHandler extends EditFieldHandler im trigger && trigger.focus(); } - onFocusOut():void { - } - handleUserKeydown(event:JQuery.TriggeredEvent, onlyCancel?:boolean):void { } diff --git a/frontend/src/app/shared/components/fields/edit/editing-portal/edit-field-handler.ts b/frontend/src/app/shared/components/fields/edit/editing-portal/edit-field-handler.ts index 6d9c12f33725..2a78b1d51a4d 100644 --- a/frontend/src/app/shared/components/fields/edit/editing-portal/edit-field-handler.ts +++ b/frontend/src/app/shared/components/fields/edit/editing-portal/edit-field-handler.ts @@ -144,11 +144,6 @@ export abstract class EditFieldHandler extends UntilDestroyedMixin { */ public abstract isChanged():boolean; - /** - * Handle focus loss - */ - public abstract onFocusOut():void; - public abstract setErrors(newErrors:string[]):void; public previewContext(resource:HalResource):string|undefined { diff --git a/frontend/src/app/shared/components/fields/edit/field-handler/hal-resource-edit-field-handler.ts b/frontend/src/app/shared/components/fields/edit/field-handler/hal-resource-edit-field-handler.ts index 3065cda507ab..bb901b20c404 100644 --- a/frontend/src/app/shared/components/fields/edit/field-handler/hal-resource-edit-field-handler.ts +++ b/frontend/src/app/shared/components/fields/edit/field-handler/hal-resource-edit-field-handler.ts @@ -107,14 +107,6 @@ export class HalResourceEditFieldHandler extends EditFieldHandler { } } - public async onFocusOut() { - // In case of inline create or erroneous forms: do not save on focus loss - // const specialField = this.resource.shouldCloseOnFocusOut(this.fieldName); - if (this.resource.subject && this.withErrors && this.withErrors.length === 0) { - await this.handleUserSubmit(); - } - } - public setErrors(newErrors:string[]) { this.errors = newErrors; this.element.classList.toggle('-error', this.isErrorenous); diff --git a/frontend/src/app/shared/components/fields/edit/field-types/float-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/float-edit-field.component.ts index efe7407e871c..24d8ec4b5f3a 100644 --- a/frontend/src/app/shared/components/fields/edit/field-types/float-edit-field.component.ts +++ b/frontend/src/app/shared/components/fields/edit/field-types/float-edit-field.component.ts @@ -38,7 +38,6 @@ import { EditFieldComponent } from 'core-app/shared/components/fields/edit/edit- [disabled]="inFlight" [(ngModel)]="value" (keydown)="handler.handleUserKeydown($event)" - (focusout)="handler.onFocusOut()" [attr.lang]="locale" [id]="handler.htmlId" /> `, diff --git a/frontend/src/app/shared/components/fields/edit/field-types/integer-edit-field/integer-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/integer-edit-field/integer-edit-field.component.ts index dc604df8b957..ec6955b0ca7b 100644 --- a/frontend/src/app/shared/components/fields/edit/field-types/integer-edit-field/integer-edit-field.component.ts +++ b/frontend/src/app/shared/components/fields/edit/field-types/integer-edit-field/integer-edit-field.component.ts @@ -38,7 +38,6 @@ import { EditFieldComponent } from 'core-app/shared/components/fields/edit/edit- [attr.lang]="locale" [(ngModel)]="value" (keydown)="handler.handleUserKeydown($event)" - (focusout)="handler.onFocusOut()" [id]="handler.htmlId" /> `, }) diff --git a/frontend/src/app/shared/components/fields/edit/field-types/text-edit-field.component.html b/frontend/src/app/shared/components/fields/edit/field-types/text-edit-field.component.html index ef7408857103..44652e6efe0e 100644 --- a/frontend/src/app/shared/components/fields/edit/field-types/text-edit-field.component.html +++ b/frontend/src/app/shared/components/fields/edit/field-types/text-edit-field.component.html @@ -7,6 +7,5 @@ [disabled]="inFlight" [(ngModel)]="value" (keydown)="handler.handleUserKeydown($event)" - (focusout)="handler.onFocusOut()" [id]="handler.htmlId" /> diff --git a/frontend/src/app/shared/components/grids/widgets/custom-text/custom-text-edit-field.service.ts b/frontend/src/app/shared/components/grids/widgets/custom-text/custom-text-edit-field.service.ts index f723e0b4c996..b4ba148a0632 100644 --- a/frontend/src/app/shared/components/grids/widgets/custom-text/custom-text-edit-field.service.ts +++ b/frontend/src/app/shared/components/grids/widgets/custom-text/custom-text-edit-field.service.ts @@ -27,10 +27,6 @@ export class CustomTextEditFieldService extends EditFieldHandler { super(); } - onFocusOut():void { - // interface - } - public initialize(value:GridWidgetResource) { this.initializeChangeset(value); this.valueChanged$ = new BehaviorSubject(value.options.text as string); diff --git a/spec/features/work_packages/edit_work_package_spec.rb b/spec/features/work_packages/edit_work_package_spec.rb index a80ed2ddd9bd..382116ed6a17 100644 --- a/spec/features/work_packages/edit_work_package_spec.rb +++ b/spec/features/work_packages/edit_work_package_spec.rb @@ -255,12 +255,11 @@ def visit! subject_field.expect_state_text "My new subject!" end - it "submits the edit mode when changing the focus" do + it "does not close the edit mode when changing the focus" do page.find("body").click - wp_page.expect_toast(message: "Successful update") - subject_field.expect_inactive! - subject_field.expect_state_text "My new subject!" + subject_field.expect_active! + wp_page.expect_no_toaster(type: :success, message: "Successful update", wait: 1) end end end