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

Fixed an issue where the 'root' may be the component that does not have a getComponent method. #5673

Merged
merged 2 commits into from
Sep 10, 2024
Merged
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 src/utils/conditionOperators/DateGreaterThan.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class DateGeaterThan extends ConditionOperator {

let conditionTriggerComponent = null;

if (instance && instance.root) {
if (instance?.root?.getComponent) {
conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
}
Comment on lines 27 to 31
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use optional chaining on functions as well.

let conditionTriggerComponent = instance?.root?.getComponent?.(conditionalComponentPath)


Expand Down
4 changes: 2 additions & 2 deletions src/utils/conditionOperators/IsEmptyValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export default class IsEmptyValue extends ConditionOperator {
execute({ value, instance, conditionComponentPath }) {
const isEmptyValue = _.isEmpty(_.isNumber(value)? String(value): value);

if (instance && instance.root) {
const conditionTriggerComponent = instance.root?.getComponent && instance.root.getComponent(conditionComponentPath);
if (instance?.root?.getComponent) {
const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);
return conditionTriggerComponent?.isEmpty ? conditionTriggerComponent.isEmpty() : isEmptyValue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/conditionOperators/IsEqualTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export default class IsEqualTo extends ConditionOperator {
catch (e) {}
}

if (instance && instance.root) {
const conditionTriggerComponent = instance.root?.getComponent && instance.root.getComponent(conditionComponentPath);
if (instance?.root?.getComponent) {
const conditionTriggerComponent = instance.root.getComponent(conditionComponentPath);

if (
conditionTriggerComponent
Expand Down
Loading