django-unicorn icon indicating copy to clipboard operation
django-unicorn copied to clipboard

[Bug] Component key is sometimes a string and sometimes an int

Open gsxdsm opened this issue 6 months ago • 1 comments

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 -

  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?

  • [X] I checked and didn't find similar issue

Code of Conduct

  • [X] 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

gsxdsm avatar Aug 14 '24 22:08 gsxdsm