telerik / kendo-react

Issue tracker - KendoReact http://www.telerik.com/kendo-react-ui/
https://kendo-react-teal.vercel.app
Other
211 stars 39 forks source link

Scheduler dataItem bad copy #1068

Closed lkrugertogetr closed 2 years ago

lkrugertogetr commented 3 years ago

I'm submitting a...

Current behavior

props.dataItem accessed from a custom SchedulerItem is a copy of the inserted data item for some reason, and instead of being an instance of a class it is now an object where getters and methods are lost.

Expected behavior

Expect dataItem either to be a reference to an item passed in the data array in the Scheduler component or a correct copy.

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/react-rbhpac?file=app/main.tsx Look in the console, expected to log:

Inside CustomItem
<image url>
true //instanceof expected class

Instead it logs:

Inside CustomItem
undefined
false //instanceof expected class

What is the motivation or use case for changing the behavior?

I have an instance of a utility class Color in the dataItem for rendering the background color, where I want to access a getter for the hexadecimal value of the color and a method used to calculate contrast to decide the color of the text.

Environment

Package versions:

@progress/kendo-date-math
1.5.2

@progress/kendo-drawing
1.11.0

@progress/kendo-licensing
1.2.0

@progress/kendo-react-animation
4.8.0

@progress/kendo-react-buttons
4.8.0

@progress/kendo-react-dateinputs
4.8.0

@progress/kendo-react-dialogs
4.8.0

@progress/kendo-react-dropdowns
4.8.0

@progress/kendo-react-form
4.8.0

@progress/kendo-react-inputs
4.8.0

@progress/kendo-react-intl
4.8.0
@progress/kendo-react-labels
4.8.0

@progress/kendo-react-popup
4.8.0

@progress/kendo-react-scheduler
4.8.0

@progress/kendo-react-treeview
4.8.0

@types/react
17.0.19

@types/react-dom
17.0.9

prop-types
15.7.2

react
17.0.2

react-dom
17.0.2

Browser:

System:

Obviously I can just make objects out of my instances, but that seems like unnecessary and avoidable code.

kspeyanski commented 2 years ago

We've modified the clone function to now properly clone React.Element instances with version 4.11.0 of all kendo-react packages.

Please refer to the Changelog for the full list of changes: https://www.telerik.com/kendo-react-ui/components/changelogs/ui-for-react/#be637ab5-74d0-5d30-b4cb-ecf78c7a32f2