I've come across an issue that I'd like some input...
# contributing
m
I've come across an issue that I'd like some input on before making an issue on GitHub. When hiding a tab using the
SendingContentNotification
and that tab has a property using the
Umbraco.DropDown.Flexible
editor then the selected value inside that dropdown is lost when the node is saved by someone who doesn't see that tab. This behaviour is different from some other editors like the
Umbraco.RadioButtonList
or the
Umbraco.TextBox
. What causes this property editor to behave differently and is this intended? And is this something that is worth making an issue for in GitHub?
m
How are you removing the tab?
m
Copy code
cs
    public void Handle(SendingContentNotification notification)
    {
        if (IsAdmin())
        {
            return;
        }

        var content = notification.Content;
        var variants = content.Variants;

        foreach (var variant in variants)
        {

            variant.Tabs = variant.Tabs.Where(x => x.Alias != "settings");
        }
    }
This is a simplified version I've build to see if this is also an issue in Umbraco v12 but it's the same principle.
m
Instead just change the alias to "" it wont render but the validation will trigger but this is can also be removed
m
Thanks! It's actually not the Alias property but Label property that needs to be set to an empty string but that works. Thank you again for the help!
@Matt Wise small correction, setting the label to an empty string actually doesn't hide the tab. You can still click on the tab and it will open (it's just hard to click on it because there is no label). Setting the
tab.Type
to an empty string does work however.
I'd expect the
tab.IsActive
to be used in hiding the tab but setting that property to false doesn't seem to do anything.
m
Finally able to check my code 😄 So I am setting Type to empty
then on ContentPublishingNotification doing this for each property: if (enabled == false) { prop.PropertyType.ValidationRegExp = null; prop.PropertyType.Mandatory = false; }
m
For Umbraco V8 the
tab.Type
is an integer. Setting it to -1 also hides the tab in that version.
2 Views