I have started using Master pages and smart components, I don’t think the Restore on update is working as per the documentation / tutorials.
I am experiencing deleted components reappearing in child pages - after a component update, even though the components are marked as optional in the master and their restore on update is left unchecked.
My system details:
Mac OS Catalina: 10.15.7
Steps to reproduce:
Create components from elements in the DOM on index.html
Select index.html to become a master page
Reselect components in index.html and make them optional, leave restore on update unchecked
Save and reload components
Create a new page based on master (index.html), e.g. about.html
Delete the optional components from about.html and save
Edit a component on master and then update components
All deleted ‘optional’ components from about.html have been restored! Not the documented behaviour.
Thanks droidgoo, I have tried what Matjaz suggested in his response to you… which hasn’t made a difference. The issue is more to do with the Optional > Restore on update not functioning in the desired way.
Thanks for the note… the default optional behaviour you describe is not what is happening. All elements marked as optional are appearing in new instances of my master document when the new instance is created.
See image below that shows optional area being defined in the master document
EDIT: Got the zip from the support ticket, sorry and thanks!
Could you provide me with a zip file of your project. Recreating a problem like this can be a little difficult.
Sorry for the slight delay in getting back to you. I will mostly likely make either a tutorial, or at least clarify the documentation on a couple of points.
Explanation of the issue
The problem you are running into on your page is a conflict between “Master” page rules and “Component” rules. Let me try to explain. Master pages expect everything to be duplicated on child pages, except for the items marked optional. Likewise, Components expect all the elements within the definition to be used except those marked as optional. On your pages you are adding optional to the main definition. That optional is supposed to be a signal to the Master page that the particular block of code can be deleted. Instead, Pinegrow is interpreting it as an optional signal to the definition. When you update, the Master detects that elements (not marked optional) have been deleted and puts them back.
So, how can this be fixed? I guess the main question is whether you need components.
If not, you can just remove the “Component definition” action from each section, leaving the optional behind. Any Child page would then have everything the Master page has with the ability to delete any optional section that isn’t desired. The one issue with this method is that when you first create a Child page you will have to open the “Page” menu and select “Restore optional areas”
If you need to components you will have to take a slightly different route. The page where you define your components shouldn’t be the same as your Master page. Instead, you can duplicate your Master page and give it a new name. Next remove the Master page action. This page is now a factory page - it produces your components. Next, on the Master page you can add each section you want through the “Use component” action. These can now be marked as optional - this will apply at the Master page level so you can delete any section and it won’t reappear on Component update.
I hope this makes sense and helps you move forward with your project. Reach out if you still have questions or want clarification.