Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove focusout submits the field #16910

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -86,9 +84,6 @@ export abstract class WorkPackageCommentFieldHandler extends EditFieldHandler im
trigger && trigger.focus();
}

onFocusOut():void {
}

handleUserKeydown(event:JQuery.TriggeredEvent, onlyCancel?:boolean):void {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was about to push it too :)

[id]="handler.htmlId" />
`,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
[disabled]="inFlight"
[(ngModel)]="value"
(keydown)="handler.handleUserKeydown($event)"
(focusout)="handler.onFocusOut()"
[id]="handler.htmlId"
/>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions spec/features/work_packages/edit_work_package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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