• Hi,

    I found after a while what was causing some weird behavior with Greenshift Local Classes on pages I was editing.
    In fact, at least 3 cases that can get users stuck with their styling on greenshift ui:

    1: Duplicating a block with a Greenshift Local Class

    It happens when you:

    1. Create a Local Class on a block
    2. Add some styles to this class
    3. Duplicate this block

    See this screencast demo

    This is a common case, when you first create a block you want to style with a class, and then quickly add more of this block on the page and then just change maybe some content or something, like cards, testimonials, buttons/CTAs…
    In fact, this creates 2 controller blocks for this class, each one having its own styling, and the last one overriding the others.
    Imagine a big landing page, with many CTAs dispersed across the page, some of them duplicated, and others recreated manually:
    It creates a very confusing and hard to recover situation

    Reason: Duplicating a block copies “css” and “attributes” data of the block, which is what makes a block a Local Class controller, so now you have several Local Class controllers which is not expected by Greenshift

    Workaround for now: Recreate a second block manually without duplicating the first, add class[es] manually (so the blue box “Looks like this class is controlled from another box” appears), and then you can duplicate this second element anytime

    To fix a messed up page without redoing manually all your blocks, you can also try to reset thier “css” and “atrributes” on code editor, but this can become very tricky on a complex page or block

    Screencast Demo

    But if by accident you began, in your editing history, to style the class on a first block, then duplicate it, then by accident modify the styles on the second one and so on… Then, the style of your local class is now spread on different blocks…
    At this stage, it may be better to review each block styles and merge all of them in the first one, delete the other “controllers”, and re-add them manually so you’ll be in peace for the future with only one main controller for this class.

    2: Duplicating a block with a local class, having only subselectors styled and not the class itself

    It happens when you:

    1. Create a Local Class on a block
    2. Add some (1 or more) subselectors, and style those subselectors
    3. Duplicate this block

    See the screencast

    This is a common case when you want a parent block that will style its children, like a parent layout row/grid/section… you want to duplicate on the page

    Same reason as #1, but this time, as the parent blocks have is no styling, Greenshift can’t recognize any of them as a controller, “Locate block controller” button appear on all of them, cycling through each one, and then you don’t know what to do anymore to change your styling

    Workaround for now: should be like #1 (not tested), but even more tricky as now the blocks attributes become very complex with all the selectors

    3: Deleting a block controlling a Local Class

    Some times, you have a block that controls a Local Class, and some others blocks where you added this local class manually on your page (so everything is good for now, they refers to the first one).
    Then, say you want to delete the first block as you don’t need it anymore: You lose the class styling as it was saved in the first block

    See the screencast

    As the Local Class concept applies to the whole page, it is expected that, as the class is present on other blocks, the styling would be transfered to the next one to keep the styling on deletion

    Workaround for now: be careful when deleting a block with local class: if you know that another block is set to the same class (it can be hard to remember or find on complex pages though, this is why this should be automatic), then take your time and click on Copy Styles on the class controller, and then on the second block, click the class and paste styles And subselectors (if relevant).
    Then check and delete the original block

    It would be great to have all of this working in a more expected way, or even better, have some sort of tab in Gutenberg Editor to review and manage local classes

    Maybe can we start by having a little confirmation alert box that appears when deleting a block controlling a local class, and may ask if we want to keep the class (and move its attributes to an other one), or delete it along?

    Same for duplication, it may ask if we want to duplicate without becoming a duplicate local class controller (so referring to the first one for further edits), or duplicate verbatim like now (with a little text warning that this will create two controllers)

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Illia Sanz

    (@illiagreen)

    it’s expected. You use local classes in wrong way. When you create it, you should not duplicate block. Create any other block and then select local class in selector.

    documentation is on site https://greenshiftwp.com/documentation/greenshift-extra/global-and-local-class-system/

    there are many other productivity tricks

    https://youtu.be/EhwRm6is3z8

    Thread Starter Emmanuel Atsé

    (@eatse)

    Thanks for your answer!

    Indeed the way to do it for now is as you said; But you can understand that it can become very tedious, especially if someone need to recreate each time some pretty complex blocks with many subblocks.

    It kinds of defeat the purpose of classes…

    Imagine cards for booking or products with many informations and classes/subclasses. After having setup the first one, if you need again to reconstruct a new card with 10, 20 or more ? Sub-blocks and go back and forth to check how the first one is made and readd classes on each one; It’s a bit harsh instead of just be able to duplicate them with just a reference to the original local classes…

    Instead, adding just a little confirmation, or maybe a “Duplicate without local classes” button next to the normal one, would benefit to everyone and make things more clear, especially for new users, and would not be difficult to implement, isn’t it?

    Same thing for deletion

    Plugin Support Illia Sanz

    (@illiagreen)

    you don’t need to recreate anything. Please watch my video first

    and second, more detailed

    https://m.youtube.com/watch?v=n6l23KiRGFw

    Thread Starter Emmanuel Atsé

    (@eatse)

    Hi,

    I’ve already seen the two videos before, but I re-watched them carefuly and indeed they do not quite address the cases I mentioned earlier
    Also, local instances are another great feature but is not what I seek here

    So, if possible, just tell me if it’s something you might consider to support, and if I need to make a feature request maybe on the site then?

    Otherwise, I’ll look to develop a little addon on my side, so we can close this topic

    Plugin Support Illia Sanz

    (@illiagreen)

    please provide me information why you can’t use local style components because this is exactly made for your purposes

    Thread Starter Emmanuel Atsé

    (@eatse)

    Well, for several reasons, without being too long:

    Example:
    You make a simple box with a heading and some text as follows:
    > div (styled with a border)
    > h2 (styled with red color)
    > p element (unstyled)

    Happy with the design, you make some instances of this block. So far so good, you can change the div’s and heading’s styling of all the instances at once by altering the first box.
    But then you want to style the text: it only affects the first box, as it wasn’t included as a controller, because it was unstyled at first; so all p elements are unrelated to each other.

    Now you want to add some other block in the boxes, but you can’t style them all at once as they are unrelated too.
    With a local class however, it is as easy as adding a subselector and add the styling, with other benefits as well

    Or maybe now you don’t need the first box anymore (the one that controls the other instances), but if you do that, you lose the styling of all other at once

    Plugin Support Illia Sanz

    (@illiagreen)

    for this we also have features. You can add local class on parent block (where you put all other items) and then add regular classes on all sub elements. Then you can click to auto create subselectors (with BEM or no) and style everything from main class. You can add any other elements later and again auto create subselectors. This is described in video about production tips

    We also have Global class feature

    Thread Starter Emmanuel Atsé

    (@eatse)

    Thanks, indeed I use this already when making a group of similar items (local class on parent of all items)

    By this time, I managed to code an add-on that makes “Duplicate” and “Remove” be aware of local classes :

    • If duplicating a block that controls a local class, the new one will just reference the first
    • When removing a block that controls a local class, transfer the control to the next one that refers to it if any and then remove

    I made this behavior optional, a modal pops up and asks if it should act like that or as normal

    Please let me know if interested, I’ll close the issue

    Plugin Support Illia Sanz

    (@illiagreen)

    I am glad to inform that next update will have improvements in duplication logic. Now, when you make duplication, local class will be referenced to original, so, it will not duplicate local class attributes

    Thread Starter Emmanuel Atsé

    (@eatse)

    Hi, okay, great news, thanks!

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Duplicating and deleting blocks is messing with Local Class system’ is closed to new replies.