Skip to content

Commit

Permalink
Merge pull request #528 from MJedr/onchange
Browse files Browse the repository at this point in the history
add schema option to remove whitespaces
  • Loading branch information
MJedr authored Dec 2, 2021
2 parents 0923997 + 17e25f7 commit d5af66c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/primitive-field/primitive-field.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,7 @@ export class PrimitiveFieldComponent extends AbstractFieldComponent implements O

if (this.schema.onValueChange) {
// setTimeout to workaround the case when the value is changed back to previous value inside onValuChange callback
setTimeout( () => {
this.schema.onValueChange(this.path, this.value, this.jsonStoreService, this.keysStoreService);
this.validate();
}
setTimeout( () => this.schema.onValueChange(this.path, this.value, this.jsonStoreService, this.keysStoreService)
);
}
}
Expand All @@ -134,7 +131,7 @@ export class PrimitiveFieldComponent extends AbstractFieldComponent implements O
}

onValueChange(value: string) {
this.value = value;
this.value = this.schema.stripWhitespace ? value.trim() : value;
}

onSearchableDropdownSelect(value: string) {
Expand Down
5 changes: 5 additions & 0 deletions src/shared/interfaces/schema-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,9 @@ export interface SchemaOption {
* Names of templates to be put as extra custom items to title dropdown.
*/
titleDropdownItemTemplateNames?: Array<string>;

/**
* Configuration for striping whitespaces from field value
*/
stripWhitespace?: boolean;
}

0 comments on commit d5af66c

Please sign in to comment.