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

FIX JS Console errors and warnings #1698

Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ SearchableDropdownField.propTypes = {
multi: PropTypes.bool.isRequired,
name: PropTypes.string.isRequired,
placeholder: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
onChange: PropTypes.func,
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 don't think that this method is always required. This recommendation gives advice to use defaultProps instead of isRequired if we are not sure that this value will be provided.

options: PropTypes.arrayOf(PropTypes.object),
optionUrl: PropTypes.string,
passRef: PropTypes.bool.isRequired,
searchable: PropTypes.bool.isRequired,
value: PropTypes.any.isRequired,
Copy link
Contributor Author

@sabina-talipova sabina-talipova Mar 4, 2024

Choose a reason for hiding this comment

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

Here as well. We don't have any values in a new field and pass value as null.

value: PropTypes.any,
SelectComponent: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).isRequired,
AsyncSelectComponent: PropTypes.oneOfType([PropTypes.object, PropTypes.func]).isRequired,
};
Expand All @@ -184,6 +184,8 @@ SearchableDropdownField.defaultProps = {
multi: false,
passRef: true,
placeholder: '',
onChange: () => {},
value: '',
SelectComponent: Select,
AsyncSelectComponent: AsyncSelect,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ window.jQuery.entwine('ss', ($) => {
const cmsContent = this.closest('.cms-content').attr('id');
const context = cmsContent ? { context: cmsContent } : {};
const schema = this.data('schema');
this.data('entwine-value', schema.value);
const Root = createRoot(this[0]);
const ReactField = loadComponent(schema.component, context);
this.setRoot(Root);
this.setComponent(ReactField);
this._super();
this.refresh();
if (schema) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In first load Entwine this.data('schema') method returns null.

this.data('entwine-value', schema.value);
const Root = createRoot(this[0]);
const ReactField = loadComponent(schema.component, context);
this.setRoot(Root);
this.setComponent(ReactField);
this._super();
this.refresh();
}
},

onunmatch() {
const Root = this.getRoot();
Root.unmount();
if (Root) {
Root.unmount();
}
},

getProps() {
Expand Down
Loading