Skip to content

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

feat(frontend): allow filename rename validation on blur

johavenda930b8be9d5
diff --git a/frontend/src/app/common/directives/input-edit.directive.ts b/frontend/src/app/common/directives/input-edit.directive.ts
index fe17312c..06770cf2 100644
--- a/frontend/src/app/common/directives/input-edit.directive.ts
+++ b/frontend/src/app/common/directives/input-edit.directive.ts
@@ -33,6 +33,7 @@ export class InputEditDirective implements OnInit {
@HostListener('blur')
onBlur() {
+ this.validateInput()
if (this.disableOnBlur) {
this.disableEdit()
}
@@ -43,18 +44,7 @@ export class InputEditDirective implements OnInit {
if (this.disableKeyboard) {
return
}
- if (!this.elementRef.nativeElement.value) {
- this.setIncorrectForm()
- } else {
- if (this.elementRef.nativeElement.value === this.inputObject[this.inputField]) {
- this.setCorrectForm()
- this.disableEdit()
- } else {
- this.setCorrectForm()
- this.updateObject.next({ object: this.inputObject, name: this.elementRef.nativeElement.value })
- this.disableEdit()
- }
- }
+ this.validateInput()
}
@HostListener('keyup.esc')
@@ -93,6 +83,21 @@ export class InputEditDirective implements OnInit {
this.renderer.setStyle(this.elementRef.nativeElement, 'border-color', this.primaryColor)
}
+ private validateInput() {
+ if (!this.elementRef.nativeElement.value) {
+ this.setIncorrectForm()
+ } else {
+ if (this.elementRef.nativeElement.value === this.inputObject[this.inputField]) {
+ this.setCorrectForm()
+ this.disableEdit()
+ } else {
+ this.setCorrectForm()
+ this.updateObject.next({ object: this.inputObject, name: this.elementRef.nativeElement.value })
+ this.disableEdit()
+ }
+ }
+ }
+
private disableEdit() {
this.setParentDraggable('true')
this.renamingInProgress.emit(false)