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

React LabelGroup linking fix #271

Merged
merged 5 commits into from
Jan 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/components/LabelGroup/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ class LabelGroup extends BaseComponent <LabelGroupArgs, any> {
if (Array.isArray(this.props.children) || !this.props.children) {
throw new Error('A LabelGroup must contain a single child react component');
}
const labelFieldChild = (this.props.children as { type: any, props: any });
Copy link
Contributor

@willeastcott willeastcott Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not straightforward to provide types here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the types and included an explanation.

const labelField = new labelFieldChild.type.ctor(labelFieldChild.props);
if (labelFieldChild.props.link) {
labelField.link(labelFieldChild.props.link.observer, labelFieldChild.props.link.path);
}
this.element = new this.elementClass({
...this.props,
dom: nodeElement,
container: containerElement,
parent: undefined,
// @ts-ignore
field: new this.props.children.type.ctor(this.props.children.props)
field: labelField
});
};

Expand Down