You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The "key" for a component when passed in through a template is usually passed in as a number, however when a component gets deserialized from a server call it is parsed as a string. This causes sporadic bugs with method calls when you pass in a component key as the target.
Expected behaviour
Component keys should always be a string or a number - or the comparison for key lookup in unicorn.js could use type coercion -
if (_component.key === componentNameOrKey) {
component = _component;
}
if (_component.key == componentNameOrKey) {
component = _component;
}
But that seems a bit hacky.
Screenshots / Screenrecords
N/A
Steps to reproduce
No response
What browsers are you seeing the problem on?
Chrome
👀 Have you checked for similar open issues?
I checked and didn't find similar issue
Code of Conduct
I agree to follow this project's Code of Conduct
Are you willing to work on this issue ?
No, someone else can work on it
The text was updated successfully, but these errors were encountered:
Actually, doing the type coercion is JS seems to be the best approach. Opened PR - #728
I considered casting the key to a string in the templatetag, however this means that you will always have to remember to wrap the key var in the JS with quotes - ex: Unicorn.call('{{mykey}}', 'function') vs Unicorn.call({{mykey}}, 'function') and could break existing code. Letting JS do the type coercion is the cleanest approach and there doesn't seem to be much risk in this type coercion always happening (ex: when would two unique components have the same key value but of different types? Seems impossible).
Bug Description
The "key" for a component when passed in through a template is usually passed in as a number, however when a component gets deserialized from a server call it is parsed as a string. This causes sporadic bugs with method calls when you pass in a component key as the target.
Expected behaviour
Component keys should always be a string or a number - or the comparison for key lookup in unicorn.js could use type coercion -
But that seems a bit hacky.
Screenshots / Screenrecords
N/A
Steps to reproduce
No response
What browsers are you seeing the problem on?
Chrome
👀 Have you checked for similar open issues?
Code of Conduct
Are you willing to work on this issue ?
No, someone else can work on it
The text was updated successfully, but these errors were encountered: