winter icon indicating copy to clipboard operation
winter copied to clipboard

dependsOn triggers infinite loop

Open Mrkbingham opened this issue 3 years ago • 9 comments

Winter CMS Build

1.1

PHP Version

7.4

Database engine

MySQL/MariaDB

Plugins installed

No response

Issue description

When a model has two fields that are dependent upon one another, an infinite loop occurs when the dependants are refreshed (line ~189 of winter.form.js: $('[data-field-name="' + toRefresh.fields[0] + '"]').trigger('change')

Appears to be related to this update: https://github.com/wintercms/winter/commit/712843d3c231432cefcc3fd5728518e43f73cd33#diff-cf4c08be53eb135693cb4e0424261e5d15c7475d92abc4c87aff32cb81266413

Steps to replicate

Model setup:

alpha_field_one:
    type: switch
    dependsOn:
        - alpha_field_two
alpha_field_two:
    type: switch
    dependsOn:
        - alpha_field_one

Workaround

No response

Mrkbingham avatar Jan 25 '22 00:01 Mrkbingham

Why do you have a circular dependency in the first place?

LukeTowers avatar Jan 25 '22 01:01 LukeTowers

In my use case I would like both fields to be available at the outset (fresh page load/create), but if one switch is enabled, then the other option should be hidden (or disabled)

Mrkbingham avatar Jan 25 '22 03:01 Mrkbingham

Also worth noting that I have to use dependsOn and can’t use trigger as there are other fields that are impacted by these two switches

Mrkbingham avatar Jan 25 '22 03:01 Mrkbingham

@Mrkbingham why don't you use a single balloon-selector field instead to toggle between the two states?

LukeTowers avatar Jan 26 '22 00:01 LukeTowers

@LukeTowers each field has a complex knock-on effect depending upon selection, so I need a desc explaining each option. I think the radio selector might be my since it supports the secondary description.

It'd be great to get something like a console.error() on a circular logic loop in winter.form.js

Mrkbingham avatar Feb 02 '22 17:02 Mrkbingham

This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days. If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue. If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

github-actions[bot] avatar Apr 04 '22 00:04 github-actions[bot]

This issue will be closed and archived in 3 days, as there has been no activity in this issue for the last 6 months. If this issue is still relevant or you would like to see it actioned, please respond within 3 days. If this issue is critical for your business, please reach out to us at [email protected].

github-actions[bot] avatar Oct 04 '22 00:10 github-actions[bot]

This issue will be closed and archived in 3 days, as there has been no activity in this issue for the last 6 months. If this issue is still relevant or you would like to see it actioned, please respond within 3 days. If this issue is critical for your business, please reach out to us at [email protected].

github-actions[bot] avatar Apr 05 '23 00:04 github-actions[bot]

This issue will be closed and archived in 3 days, as there has been no activity in this issue for the last 6 months. If this issue is still relevant or you would like to see it actioned, please respond within 3 days. If this issue is critical for your business, please reach out to us at [email protected].

github-actions[bot] avatar Oct 07 '23 00:10 github-actions[bot]

This issue will be closed and archived in 3 days, as there has been no activity in this issue for the last 6 months. If this issue is still relevant or you would like to see it actioned, please respond within 3 days. If this issue is critical for your business, please reach out to us at [email protected].

github-actions[bot] avatar Apr 09 '24 00:04 github-actions[bot]