Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(frontend:files): initialize file selection after dialog view init

johaven9d0fe086bdbe
diff --git a/frontend/src/app/applications/files/components/dialogs/files-new-dialog.component.ts b/frontend/src/app/applications/files/components/dialogs/files-new-dialog.component.ts
index ee0357f8..220da3d8 100644
--- a/frontend/src/app/applications/files/components/dialogs/files-new-dialog.component.ts
+++ b/frontend/src/app/applications/files/components/dialogs/files-new-dialog.component.ts
@@ -1,5 +1,5 @@
import { KeyValuePipe } from '@angular/common'
-import { Component, ElementRef, EventEmitter, HostListener, inject, Input, OnInit, Output, ViewChild } from '@angular/core'
+import { AfterViewInit, Component, ElementRef, EventEmitter, HostListener, inject, Input, OnInit, Output, ViewChild } from '@angular/core'
import { FormsModule } from '@angular/forms'
import { FaIconComponent } from '@fortawesome/angular-fontawesome'
import { faCaretDown, faFileAlt, faFolderClosed, faGlobe } from '@fortawesome/free-solid-svg-icons'
@@ -18,7 +18,7 @@ import { FilesService } from '../../services/files.service'
templateUrl: 'files-new-dialog.component.html',
imports: [FaIconComponent, L10nTranslateDirective, BsDropdownModule, FormsModule, L10nTranslatePipe, AutofocusDirective, KeyValuePipe]
})
-export class FilesNewDialogComponent implements OnInit {
+export class FilesNewDialogComponent implements OnInit, AfterViewInit {
@Input() files: FileModel[]
@Input() inputType: 'file' | 'directory' | 'download'
@Output() refreshFiles = new EventEmitter()
@@ -45,13 +45,18 @@ export class FilesNewDialogComponent implements OnInit {
this.fileProp.name = `${this.layout.translateString('New document')}${this.docTypeExtension(this.selectedDocType)}`
this.fileProp.title = 'New document'
this.fileProp.placeholder = 'Document name'
- this.updateFileSelection()
} else {
this.fileProp.title = 'New folder'
this.fileProp.placeholder = 'Folder name'
}
}
+ ngAfterViewInit() {
+ if (this.inputType === 'file') {
+ this.updateFileSelection()
+ }
+ }
+
onSelectDocType(docType: string) {
this.selectedDocType = docType
const pos = this.fileNamePosition()