-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 depends field not working for radio elements #11539
Fix depends field not working for radio elements #11539
Conversation
This is just an initial implementation of the fix the promote discussion, although it works I'm open to suggestions on best practices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract line this.trackChange(null, idTo, elementsMap[idTo]);
out of if/else and check test with codeStyle: Travis(289515174)
lib/web/mage/adminhtml/form.js
Outdated
@@ -402,6 +402,17 @@ define([ | |||
); | |||
this.trackChange(null, idTo, elementsMap[idTo]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract this line out of if/else
lib/web/mage/adminhtml/form.js
Outdated
'change', | ||
this.trackChange.bindAsEventListener(this, idTo, elementsMap[idTo]) | ||
); | ||
} | ||
this.trackChange(null, idTo, elementsMap[idTo]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract this line out of if/else
1e7d9d4
to
5ac8f9f
Compare
@osrecio Thanks for the comments, I went ahead and made the recommended changes. |
Looks ok for me |
lib/web/mage/adminhtml/form.js
Outdated
values = valuesFrom[idFrom].values; | ||
fromId = $(idFrom + values[0]); | ||
radioFrom = $$('[name="' + fromId.name + '"]:checked'); | ||
isInArray = values.indexOf(radioFrom[0].value) != -1; //eslint-disable-line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add check on radioFrom.length > 0
(in case when none is selected), make strict equality and remove eslint-disable-line
707a952
to
427bdca
Compare
@omiroshnichenko Thanks for your input I just made the proposed changes. |
lib/web/mage/adminhtml/form.js
Outdated
// Check if radio button | ||
values = elementsMap[idTo][idFrom].values; | ||
fromId = $(idFrom + values[0]); | ||
radioFrom = $$('[name="' + fromId.name + '"]'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After testing was detected that additional check must be added
radioFrom = fromId ? $$('[name="' + fromId.name + '"]') : false;
lib/web/mage/adminhtml/form.js
Outdated
} else { | ||
values = valuesFrom[idFrom].values; | ||
fromId = $(idFrom + values[0]); | ||
radioFrom = $$('[name="' + fromId.name + '"]:checked'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same check here
radioFrom = fromId ? $$('[name="' + fromId.name + '"]:checked') : [];
427bdca
to
0031a1c
Compare
@omiroshnichenko Thanks just updated the PR with the changes |
Great work @jahvi @okorshenko this fix should be used also in 2.3-develop branch. Why don't I see it? |
It is on the way to 2.3-develop branch. Testing now |
…pends field is not exist
Fixes issue with configuration fields not toggling when
<depends>
is used on radio elements.Description
Currently the
<depends>
field only works when used on elements ofselect
type, this PR aims to replicate the same functionality for fields withradios
type.Fixed Issues (if relevant)
Manual testing scenarios
radios
and corresponding field that dependant on one of its values as mentioned it <depends> field doesn't work in system.xml for "radios" fields #9360Contribution checklist