mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Prevent close button 'stealing' focus from modal input fields
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)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // we wait to enable the close button so it doesnt pull browser focus 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() {
 | 
			
		||||
@@ -31,7 +33,7 @@ export class SaveViewConfigDialogComponent implements OnInit {
 | 
			
		||||
    this._defaultName = value
 | 
			
		||||
    this.saveViewConfigForm.patchValue({name: value})
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  saveViewConfigForm = new FormGroup({
 | 
			
		||||
    name: new FormControl(''),
 | 
			
		||||
    showInSideBar: new FormControl(false),
 | 
			
		||||
@@ -39,6 +41,10 @@ export class SaveViewConfigDialogComponent implements OnInit {
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  ngOnInit(): void {
 | 
			
		||||
    // wait to enable close button so it doesnt steal focus form input
 | 
			
		||||
    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