Geta / geta-optimizely-genericlinks

An extensive alternative to LinkItemCollection in Optimizely.
Apache License 2.0
4 stars 0 forks source link

Link text disappearing from attribute dictionary on value change #23

Open madritz opened 1 year ago

madritz commented 1 year ago

Hi

I'm noticing that the link text value gets stored into the attribute dictionary the first time its added. But when we modify its value subsequently, it disappears from the attribute dictionary. We have some validation applied to the Link text and title fields, that we are applying by looking at the attribute collection. But because of this behavior, its only getting applied to the title and never the text.

Please review and provide feedback.

madritz commented 1 year ago

Actually, i just tested with new link and it didnt save link text for new link either in the attribute dictionary. But i see it there for existing links. So is this a recent change in one of the latest versions? any reason behind this?

svenrog commented 10 months ago

I've tried reproducing this and this is what I've come up with.

The LinkModel from the dojo widget be passing a .text property among the attributes, but the serialized model in the CMS doesn't contain this.

The current property implementation is based on the logic in Optimizelys LinkItemCollection which serializes to a html a element. Here is what is stored <links><a title="{title}">{text}</a></links>.

As you can see this places "text" in a different place than the other properties and is the reason for this odd behaviour. This might be subject to change in the future as there has been talk about changing this underlying model to allow for nested data structures.