Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(TypeScript): support form binding with optional fields and objects #8847

Merged
merged 2 commits into from Aug 21, 2020

Conversation

platosha
Copy link
Contributor

@platosha platosha commented Aug 12, 2020

BREAKING CHANGE: TypeScript the value property of BinderNode now has optionally undefined type for non-initialised optional fields.

In terms of forms, an object field could be used in both ways: as an individual field or a grouping for the object’s nested fields.

Previously, the optional fields in empty form value objects were initialised by the client-side binder with a generated value when a BinderNode (or a form binding) is created for such fields. Such a behavior works well with grouping object fields, but makes it problematic to bind an individual optional field of object type by making empty value already defined.

With this change, the client-side form binder skips initialising optional fields, keeping their values undefined, unless there is a binding for a nested field inside an optional parent object.

For example: with a binding for model.optionalObject will have a corresponding empty form value of {"optionalObject": undefined}, however, with a binding of model.optionalObject.nestedString, the empty form value will contain a generated object: {"optioanlObject": {"nestedString": ""}}.

@platosha platosha added the hilla Issues related to Hilla label Aug 12, 2020
@platosha platosha self-assigned this Aug 12, 2020
@platosha platosha force-pushed the ap/feature/forms/null-object-combo-box branch from 047cfbc to badae56 Compare August 13, 2020 10:29
@platosha platosha changed the title [WIP]: feat(TypeScript): support form binding of combo-box to object [WIP]: feat(TypeScript): support form binding with optional fields and objects Aug 13, 2020
@platosha platosha changed the title [WIP]: feat(TypeScript): support form binding with optional fields and objects feat(TypeScript): support form binding with optional fields and objects Aug 13, 2020
@platosha platosha force-pushed the ap/feature/forms/null-object-combo-box branch from badae56 to 0958de4 Compare August 13, 2020 10:52
@platosha platosha force-pushed the ap/feature/forms/null-object-combo-box branch from 0958de4 to 4a4e44b Compare August 13, 2020 13:52
@vaadin-bot vaadin-bot added +0.1.0 and removed +0.0.1 labels Aug 13, 2020
@platosha platosha force-pushed the ap/feature/forms/null-object-combo-box branch from 4a4e44b to e4f14b3 Compare August 14, 2020 11:39
@platosha platosha marked this pull request as ready for review August 14, 2020 11:41
@platosha platosha force-pushed the ap/feature/forms/null-object-combo-box branch from e4f14b3 to f4792dd Compare August 14, 2020 11:43
Haprog
Haprog previously approved these changes Aug 14, 2020
@vaadin-bot vaadin-bot added +1.0.0 and removed +0.1.0 labels Aug 14, 2020
BREAKING CHANGE: TypeScript the `value` property of `BinderNode` now has
optionally `undefined` type for non-initialised optional fields.

In terms of forms, an object field could be used in both ways: as
an individual field or a grouping for the object’s nested fields.

Previously, the optional fields in empty form value objects were initialised
by the client-side binder with a generated value when `BinderNode` or
form binding is created for such fields. Such a behavior works well with
grouping object fields, but makes it problematic to bind an individual
optional field of object type by making empty value already defined.

With this change, the client-side form binder skips initialising
optional fields, keeping their values `undefined`, unless there is
a binding for a nested field inside an optional parent object.

For example: with a binding for `model.optionalObject` will have
a corresponding empty form value of `{"optionalObject": undefined}`,
however, with a binding of `model.optionalObject.nestedString`, the
empty form value will contain a generated object: `{"optioanlObject":
{"nestedString": ""}}`.
@platosha platosha merged commit cfe589a into master Aug 21, 2020
@platosha platosha deleted the ap/feature/forms/null-object-combo-box branch August 21, 2020 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hilla Issues related to Hilla +0.0.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants