Skip to content

Commit

Permalink
Fix all props being set inside data and initial data props of form cl…
Browse files Browse the repository at this point in the history
…ient
  • Loading branch information
Jerome (Thavarshan) Thayananthajothy committed Oct 17, 2023
1 parent f397e45 commit 7a9c44a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed

* Fix props being set directly on form client
* Fix all props being set inside data and initial data props of form client

## [v0.0.10](https://github.com/formlinkjs/formlink/compare/v0.0.9...v0.0.10) - 11-10-2023

Expand Down
1 change: 1 addition & 0 deletions src/clients/form.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('Form', () => {
const results = await form.get('/resource/1', {
onSuccess: ({ data, status }: any) => {
expect(status).toBe(200);
expect(data.foo).toBe('bar');

return data;
}
Expand Down
2 changes: 1 addition & 1 deletion src/clients/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class Form implements FormInterface {
public getProxy (instance: Form): Form {
return new Proxy(instance, {
set: (obj: Form, prop: string, value) => {
_.set(obj.data, prop, value);
_.set(obj, prop, value);

if (
_.includes(reservedFieldNames, prop) &&
Expand Down
9 changes: 9 additions & 0 deletions src/interfaces/clients/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,13 @@ export interface Form {
* @return {void}
*/
setIsDirty (state: boolean): void;

/**
* Get initial/original value of given field.
*
* @param {string} field
*
* @return {any}
*/
getInitial (field: string): any;
}

0 comments on commit 7a9c44a

Please sign in to comment.