mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge pull request #370 from shamoon/fix/issue-350
Prevent close button in modal dialogs 'stealing' focus
This commit is contained in:
		| @@ -27,6 +27,8 @@ export abstract class EditDialogComponent<T extends ObjectWithId> implements OnI | ||||
|  | ||||
|   networkActive = false | ||||
|  | ||||
|   closeEnabled = false | ||||
|  | ||||
|   error = null | ||||
|  | ||||
|   abstract getForm(): FormGroup | ||||
| @@ -37,6 +39,11 @@ export abstract class EditDialogComponent<T extends ObjectWithId> implements OnI | ||||
|     if (this.object != null) { | ||||
|       this.objectForm.patchValue(this.object) | ||||
|     } | ||||
|  | ||||
|     // wait to enable close button so it doesnt steal focus from input since its the first clickable element in the DOM | ||||
|     setTimeout(() => { | ||||
|       this.closeEnabled = true | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   getCreateTitle() { | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| <form [formGroup]="saveViewConfigForm" (ngSubmit)="save()"> | ||||
|   <div class="modal-header"> | ||||
|     <h4 class="modal-title" id="modal-basic-title" i18n>Save current view</h4> | ||||
|     <button type="button" class="close" aria-label="Close" (click)="cancel()"> | ||||
|     <button type="button" [disabled]="!closeEnabled" class="close" aria-label="Close" (click)="cancel()"> | ||||
|       <span aria-hidden="true">×</span> | ||||
|     </button> | ||||
|   </div> | ||||
|   | ||||
| @@ -20,6 +20,8 @@ export class SaveViewConfigDialogComponent implements OnInit { | ||||
|   @Input() | ||||
|   buttonsEnabled = true | ||||
|  | ||||
|   closeEnabled = false | ||||
|  | ||||
|   _defaultName = "" | ||||
|  | ||||
|   get defaultName() { | ||||
| @@ -39,6 +41,10 @@ export class SaveViewConfigDialogComponent implements OnInit { | ||||
|   }) | ||||
|  | ||||
|   ngOnInit(): void { | ||||
|     // wait to enable close button so it doesnt steal focus from input since its the first clickable element in the DOM | ||||
|     setTimeout(() => { | ||||
|       this.closeEnabled = true | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   save() { | ||||
|   | ||||
| @@ -1,12 +1,11 @@ | ||||
| <form [formGroup]="objectForm" (ngSubmit)="save()"> | ||||
|   <div class="modal-header"> | ||||
|     <h4 class="modal-title" id="modal-basic-title">{{getTitle()}}</h4> | ||||
|     <button type="button" class="close" aria-label="Close" (click)="cancel()"> | ||||
|     <button type="button" [disabled]="!closeEnabled" class="close" aria-label="Close" (click)="cancel()"> | ||||
|       <span aria-hidden="true">×</span> | ||||
|     </button> | ||||
|   </div> | ||||
|   <div class="modal-body"> | ||||
|  | ||||
|     <app-input-text i18n-title title="Name" formControlName="name" [error]="error?.name"></app-input-text> | ||||
|     <app-input-select i18n-title title="Matching algorithm" [items]="getMatchingAlgorithms()" formControlName="matching_algorithm"></app-input-select> | ||||
|     <app-input-text *ngIf="patternRequired" i18n-title title="Matching pattern" formControlName="match"></app-input-text> | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| <form [formGroup]="objectForm" (ngSubmit)="save()"> | ||||
|     <div class="modal-header"> | ||||
|       <h4 class="modal-title" id="modal-basic-title">{{getTitle()}}</h4> | ||||
|       <button type="button" class="close" aria-label="Close" (click)="cancel()"> | ||||
|       <button type="button" [disabled]="!closeEnabled" class="close" aria-label="Close" (click)="cancel()"> | ||||
|         <span aria-hidden="true">×</span> | ||||
|       </button> | ||||
|     </div> | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
|   <form [formGroup]="objectForm" (ngSubmit)="save()"> | ||||
|     <div class="modal-header"> | ||||
|       <h4 class="modal-title" id="modal-basic-title">{{getTitle()}}</h4> | ||||
|       <button type="button" class="close" aria-label="Close" (click)="cancel()"> | ||||
|       <button type="button" [disabled]="!closeEnabled" class="close" aria-label="Close" (click)="cancel()"> | ||||
|         <span aria-hidden="true">×</span> | ||||
|       </button> | ||||
|     </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonas Winkler
					Jonas Winkler