Typically, when I add a component in app studio, and put an onCreate event on it, it’ll fire once. With more than one dashboard I’m working on, I noted that the onCreate event is firing twice. Enabling debug and using hotkey ctrl-alt-L to display all components/properties shows me there are two instances of the component being created by Kinetic on form load:
Note that the GUID/id of the component is the same, also if I check the output from the GetApp REST call, i don’t see a duplicate instance of this component on the layout. It looks like Kinetic is creating a duplicate copy when building the UI. Anyone run into this before or have an idea what might trigger it? Off to report another bug with App Studio!
Further testing looks like this is applicable to any component located within a Panel Card’s “Expanded Header Components” area (the container above the main panel card area)
Dragging the component into the main panel card area creates only one instance of the component.
Dragging the same component into the extended header components area causes kinetic to generate a duplicate of the component.
Testing shows that both are rendered and active, if i use control-alt-L to change hidden to true on one of them, it will still remain visible. I have to change hidden to true on both of them for it to hide. onCreate events will fire once when the component is contained within the Panel Card, and twice when the component is contained with the Panel Card’s Expanded Header Component area.
This can be verified by pressing control-alt-8 to switch into debug mode, and control-alt-L to display components in the debug mode console, then pressing F12 to open dev tools, and navigating to the “Console” tab.
You will see duplicate instances of the button, in the properties for each instance, you will see componentInstance._autoIdNum and componentInstance.ngContext differ for each instance of the component.
Furthermore, behavior of the panel card is such that if you click the up-arrow icon to “roll up” the panel, all components within it get destroyed. (the only component present on the page after a panel roll-up is the panel card)
Clicking the down arrow icon to expand the panel card will create the components on-the-fly, which fires the component’s onCreate trigger again.
With this duplicating behavior, only one instance of the component is destroyed and created on the unexpand/expand action, so the duplicate onCreate event only fires twice during initial form load. rolling up the panel card and expanding it again will only fire the event once (as the duplicate copy of the component doesn’t get destroyed/created, so doesn’t fire the event)