I’m seeing this too. Cannot say if this is regression. I think measurement 
following added child happens too soon, i.e. before createChildren() finishes. 
I might have a fix for this, I’ll update, and will appreciate feedback.

From: Edward Stangler<mailto:estang...@bradmark.com>
Sent: Thursday, December 23, 2021 5:18 AM
To: dev@royale.apache.org<mailto:dev@royale.apache.org>
Subject: Re: FormItem preferredWidth error


If you could provide a small test case, that would be helpful.

I would think there are two commit pulls to try to narrow down what changed:

1.  Before spark-dynamic-layout-jan-2021 and greg-dove deferred changes
(December 2021):  c256c4342e1d2e16a938ab08ef9049c94489685c

2.  Before ChildResize (October 2021):
ad38c5ad7a1a3a627b1882e299d4dd7674daada2



On 12/22/2021 7:39 PM, GAbe Barbosa wrote:
> Hi Folks,
>
> I'm in need of some help. I recently downloaded the latest build of the
> js-only sdk #3885( before I was using #3502) Using GitHub that places that
> last commit around Sep 14 or so for #3502
>
> While starting my app I now get this error:
>
> FormItem.js:667 Uncaught TypeError: Cannot read properties of undefined
> (reading 'measuredWidth')
>     at mx.containers.FormItem.getPreferredLabelWidth (FormItem.js:667)
>     at mx.containers.Form.calculateLabelWidth (Form.js:252)
>     at mx.containers.FormItem.mx_containers_FormItem_calculateLabelWidth
> (FormItem.js:686)
>     at mx.containers.FormItem.mx_containers_FormItem_measureVertical
> (FormItem.js:258)
>     at mx.containers.FormItem.measure (FormItem.js:223)
>     at mx.containers.FormItem.get__measuredWidth (FormItem.js:983)
>     at
> mx.containers.FormItem.mx.core.Container.http_$$www_adobe_com$2006$flex$mx$internal__childAdded
> (Container.js:353)
>     at mx.containers.FormItem.mx.core.UIComponent.addElement
> (UIComponent.js:2683)
>     at mx.containers.FormItem.mx.core.Container.addElement
> (Container.js:448)
>     at mx.containers.FormItem.addElement (FormItem.js:808)
>
> It looks like labelObj is undefined because createChildren doesn't get
> called before getPreferredLabelWidth
>
> I've compared the stack traces from #3885 and #3502 and very different
> paths are being taken. Here are the relevant parts:
>
>
> From #3885
> mx.containers.FormItem.getPreferredLabelWidth (FormItem.js:667)
> mx.containers.Form.calculateLabelWidth (Form.js:252)
> mx.containers.FormItem.mx_containers_FormItem_calculateLabelWidth
> (FormItem.js:686)
> mx.containers.FormItem.mx_containers_FormItem_measureVertical
> (FormItem.js:258)
> mx.containers.FormItem.measure (FormItem.js:223)
> mx.containers.FormItem.get__measuredWidth (FormItem.js:983)
> mx.core.Container.http_$$www_adobe_com$2006$flex$mx$internal__childAdded
> (Container.js:353)
> mx.core.UIComponent.addElement (UIComponent.js:2683)
> mx.core.Container.addElement (Container.js:448)
> mx.containers.FormItem.addElement (FormItem.js:808)
> org.apache.royale.html.beads.ContainerView.addViewport (ContainerView.js:50)
> org.apache.royale.html.beads.ContainerView.set__strand (ContainerView.js:83)
> org.apache.royale.core.ElementWrapper.addBead (ElementWrapper.js:117)
> org.apache.royale.core.HTMLElementWrapper.addBead (HTMLElementWrapper.js:43)
> org.apache.royale.core.UIBase.addBead (UIBase.js:371)
> org.apache.royale.utils.loadBeadFromValuesManager
> (loadBeadFromValuesManager.js:41)
> org.apache.royale.core.UIBase.loadBeads (UIBase.js:570)
> org.apache.royale.core.UIBase.addedToParent (UIBase.js:552)
> mx.core.UIComponent.addedToParent (UIComponent.js:497)
> mx.core.Container.addedToParent (Container.js:202)
>
> From #3502
> mx.containers.FormItem.getPreferredLabelWidth (FormItem.js:667)
> mx.containers.Form.calculateLabelWidth (Form.js:252)
> mx.containers.FormItem.mx_containers_FormItem_calculateLabelWidth
> (FormItem.js:686)
> mx.containers.FormItem.mx_containers_FormItem_updateDisplayListVerticalChildren
> (FormItem.js:439)
> mx.containers.FormItem.updateDisplayList (FormItem.js:404)
> mx.containers.FormItem.updateFormItemDisplayList (FormItem.js:429)
> mx.containers.FormItem.FormItemLayout.updateDisplayList (FormItem.js:1155)
> mx.containers.beads.BoxLayout.layout (BoxLayout.js:107)
> org.apache.royale.core.LayoutBase.performLayout (LayoutBase.js:243)
> org.apache.royale.core.LayoutBase.handleLayoutNeeded (LayoutBase.js:150)
> org.apache.royale.events.EventDispatcher.fireListeners
> (EventDispatcher.js:97)
> goog.events.EventTarget.dispatchEventInternal_ (eventtarget.js:382)
> org.apache.royale.events.EventDispatcher.dispatchEvent
> (EventDispatcher.js:72)
> org.apache.royale.core.ElementWrapper.dispatchEvent (ElementWrapper.js:231)
> mx.core.UIComponent.invalidateSize (UIComponent.js:1127)
> mx.controls.Label.set__text (Label.js:262)
> mx.containers.FormItem.commitProperties (FormItem.js:135)
> mx.containers.FormItem.createChildren (FormItem.js:123)
> mx.core.UIComponent.initialize (UIComponent.js:973)
> mx.core.UIComponent.addedToParent (UIComponent.js:504)
>
> Please advise how my code should change with the changes in the latest sdk.
>
> Thank you,
> Gabriel Barbosa
>

Reply via email to