When a content link is added, the Content and Title property are correctly set in the MeganavValueConverter PVC, but as soon as that content is unpublished/removed, both are null and the ItemType changes to Link (and it's still returned by the PVC).
The Id property still holds the correct content ID though, so as a workaround we currently filter these out (in our views): .Where(item => !(item.Id != 0 && item.Content == null)).
I would make sure the PVC doesn't return links to unavailable content, as that doesn't make sense anyway. Looking at the code, this was probably also intended that way:
When a content link is added, the
Content
andTitle
property are correctly set in theMeganavValueConverter
PVC, but as soon as that content is unpublished/removed, both arenull
and theItemType
changes toLink
(and it's still returned by the PVC).The
Id
property still holds the correct content ID though, so as a workaround we currently filter these out (in our views):.Where(item => !(item.Id != 0 && item.Content == null))
.I would make sure the PVC doesn't return links to unavailable content, as that doesn't make sense anyway. Looking at the code, this was probably also intended that way:
https://github.com/callumbwhyte/meganav/blob/10ebec64b37a4ce024de66b5fe0bf873794bcac5/src/Cogworks.Meganav/ValueConverters/MeganavValueConverter.cs#L65-L72
https://github.com/callumbwhyte/meganav/blob/10ebec64b37a4ce024de66b5fe0bf873794bcac5/src/Cogworks.Meganav/ValueConverters/MeganavValueConverter.cs#L100-L101
It's probably better to remove the LINQ query, return a new list (or
yield
the items) and just skip all items withId > 0
andumbracoContent == null
.