Home>Support>Commented Code Removed After Using Visual Editor

Commented Code Removed After Using Visual Editor

I have noticed a few issues with the SiteOrigin CSS plugin.

1. When I use the Visual Editor and then switch back to the normal CSS view, most, if not all, of my commented code is getting removed. This causes a real problem as I have many comments to help organize things. My comments typically look like this:

/* THIS IS COMMENTED CODE */

A few are left but most get removed.

2. After I save the CSS and then scroll down to add code to the bottom of the CSS editing window, the cursor jumps to the top of the code window which causes me to have to scroll all the way back down to add/edit the code where I want it. Perhaps this is intentional and not a bug but I find it irritating since I don’t usually add new code to the top of the window.

Please help. Thank you.

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Jeff,

    1. I was having a hard time trying to replicate this reliability. Would it be possible for you to send me something that you know reliably gets removed? That would greatly help us in resolving this issue.

    It looks like Custom CSS won’t touch CSS if it’s above a selector so maybe that’s a possible workaround for the time being.

    2. I can’t seem to replicate this one. :( To clarify, does this happen in other browsers?

  2. 8 years, 1 month ago Jeff Kyle

    For the cursor defaulting to the top of the window causing the scroll jumping, I don’t see the jumping effect in Firefox. But in both Chrome and Firefox, after saving the CSS or clicking the Custom CSS link in the left sidebar and then clicking in the editor window, the cursor still defaults to the beginning of the code at the top so I still have to manually scroll and click a second time to place the cursor where I want it for editing.

    Here is CSS code that contains commented code that is being stripped out.

    This is the CSS before using the Visual Editor:

    /* BLOCKQUOTE FORMATTING*/
    blockquote {
      color: #000;
      background: #eee;
      margin: 0 0 1.6em 0.8em;
      padding: 1.4em 1em 0.1em 1em;
      border-left: 5px solid #7F1315;
    }
    
    blockquote:before {
      display: none;
    }
    
    /* INCREASE SPACE BETWEEN PARAGRAPHS */
    #content p {
      margin-bottom: 15px;
    } 
    
    /*ALIGN VIEW CART LINK*/
    a.added_to_cart.wc-forward {
      position: absolute;
      display: block;
      bottom: -30px;
      margin-left: 60px;
    }
    
    /*ALIGN ADD TO CART BUTTONS*/
    .woocommerce ul.products li.product, .woocommerce-page ul.products li.product {
      min-height: 440px !important;
      margin-bottom: 70px;
    }
    
    a.button.add_to_cart_button, a.button.product_type_simple {
      bottom: 0px;
      position: absolute;
      margin-left: -65px;
    }
    
    /* BOLD SHOP PRICES */
    .amount {
      font-size: 18px;
      font-weight: bold;
    }

    This is the same CSS after clicking on the Visual Editor icon then switching back to the normal editor. Note that the commented code is missing:

    li {
      margin: 0 0 0.5em 0;
      padding: 0;
    }
    
    
    blockquote {
      color: #000;
      background: #eee;
      margin: 0 0 1.6em 0.8em;
      padding: 1.4em 1em 0.1em 1em;
      border-left: 5px solid #7F1315;
    }
    
    blockquote:before {
      display: none;
    }
    
    
    #content p {
      margin-bottom: 15px;
    } 
    
    
    a.added_to_cart.wc-forward {
      position: absolute;
      display: block;
      bottom: -30px;
      margin-left: 60px;
    }
    
    
    .woocommerce ul.products li.product, .woocommerce-page ul.products li.product {
      min-height: 440px !important;
      margin-bottom: 70px;
    }
    
    a.button.add_to_cart_button, a.button.product_type_simple {
      bottom: 0px;
      position: absolute;
      margin-left: -65px;
    }
    
    
    .amount {
      font-size: 18px;
      font-weight: bold;
    }
  3. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Jeff,

    I’m unable to replicate this issue. :(

    To clarify, do you have the latest version of SiteOrigin CSS installed – 1.0.7?

    To avoid any potential interference, Can you try disabling all non-SiteOrigin plugins and see if this fixes the issue? You’ll need to clear all your caches after disabling your plugins.

  4. 8 years, 1 month ago Jeff Kyle

    Yes, I’m using 1.0.7. I disabled all other plugins, cleared the cache and tested your plugin and still get the same issue. I also switched to the Twenty Fifteen theme and tested the same CSS code to see if perhaps my theme was causing a conflict and I still get the same issue using a different theme also. I have also tested in both Chrome and Firefox and see the same thing in both. I’m not sure what else could be causing this unless there is something specific to my server that is an issue.

  5. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Jeff,

    Would it be possible for you to create a temporary admin account for us so we can log in and take a look?

  6. 8 years, 1 month ago Private Message - Alex S Hi, I Work Here

    This is a private message.

  7. 8 years, 1 month ago Private Message - WordPress

    This is a private message.

  8. 8 years, 1 month ago Jeff Kyle

    The account is created.

  9. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Jeff,

    :(

    I was able to do this without losing the comments. Could you try on a different computer with, ideally, a freshly installed browser (ie. no browser’s installed).

  10. 8 years, 1 month ago Jeff Kyle

    I have just tried on 3 different computers (one PC and 2 Macs) using 3 different browsers (Chrome, Firefox and Safari) with the same results. I want to clarify that not every single comment is removed, but most of them are.

    For example, the first comment is never removed:

    /* LIST FORMATTING */

    But this comments down a little from that one is removed:

    There are certain other comments that stay consistently for some reason further down in the code.

    When testing using your temporary login, please double check and let me know if you are seeing all of my comments staying intact or only the ones I’ve been ending up with after most of the comments are stripped.

    Could it be that there may some hidden characters (such as delimiters) that your plugin is seeing and is stripping which may be affecting the comments?

  11. 8 years, 1 month ago Jeff Kyle

    Sorry, I meant to add this is the last reply…

    But this comment down a little from that one is removed:

    /* BLOCKQUOTE FORMATTING*/
  12. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Jeff,

    Not too sure what’s going on but based on what you just said, what happens if you try:

    /* BLOCKQUOTE FORMATTING */

    Notice the space.

  13. 8 years, 1 month ago Jeff Kyle

    The issue still happens even after adding the extra space after the word FORMATTING.

  14. 8 years, 1 month ago Jeff Kyle

    OK, I have narrowed the issue down to something interesting that I can reproduce consistently. My issue is related to the @media CSS rule. It seems that when this rule appears in my code, CSS comments on those code snippets are stripped out along with comments on other random snippets that don’t use the @media rule.

    Here’s an example of what I mean. The first snippet below doesn’t use the @media rule. The second one does:

    /* BOLD SHOP PRICES */.amount {  font-size: 18px;  font-weight: bold;}/* MAKE FOOTER WIDGETS RESPONSIVE ON MOBILE */@media screen and (max-width: 800px) {  .footer-widgets .col3-1 {    width: 100%;    margin: 0 auto;  }}

    If I click on the visual editor button and then come back, you’ll see that the comment on the second snippet is stripped:

    /* BOLD SHOP PRICES */.amount {  font-size: 18px;  font-weight: bold;}@media screen and (max-width: 800px){  .footer-widgets .col3-1 {    width: 100%;    margin: 0 auto;  }}

    In this case, the comment on the first snippet wasn’t affected but, for some reason, as long as the @media rule is present in my editor, the comments are consistently removed from snippets using the @media rule and randomly from other snippets that don’t use it.

    Here is a screen capture showing what I see happen when the @media rule is present in my CSS. Also note that the selector drop down on the visual editor screen doesn’t show the elements in the drop down but as one long line.:

    Here is another screen capture without the @media rule included. You’ll see that all of my comments remain intact. Note that the visual editor drop down behaves normally in this case:

    I’m not sure why some snippets that don’t use the @media rule are affected by this issue but after much testing, this is clearly what is causing the issues for me.

  15. 8 years, 1 month ago Private Message - Jeff Kyle

    This is a private message.

  16. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Jeff,

    Thank you! I’ve corrected the formatting and logged this issue. It should hopefully be fixed soon.

  17. 8 years, 1 month ago Jeff Kyle

    Thanks! So you were able to reproduce this specific issue then?

  18. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Jeff,

    Yes, although I’m still unable to replicate it with the initial CSS provided.

  19. 8 years, 1 month ago Jeff Kyle

    That's really odd. I've also been able to replicate the issue by copying my custom CSS (containing @media code) over to a completely different WordPress install running your plugin. In any case, I'm glad we were able to identify the issue.

  20. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Jeff,

    You misunderstood me. I was able to replicate it with the latest CSS but not with the original CSS that you posted here.

  21. 8 years, 1 month ago Jeff Kyle

    The reason why the very first code in this post wasn’t giving you issues by itself is because the code that I posted here to show that comments were missing didn’t have any @media rules in it. I had only posted a portion of my full custom CSS which did have @media rules in it further down in the code. My apologies for not posting the full code the first time. Lesson learned. Thanks for your patience. :-)

  22. 8 years, 1 month ago Jeff Kyle

    I see that version 1.0.8 was released today (8-15-16). Is this release intended to fix the @media issue? If so, I just did some tests and see that the issue is still happening for me.

    I did just try to post my full custom CSS here for you but the forum won’t allow me to paste it here due to its length. If you have another method that I could send my custom CSS to you for testing, please let me know. Thanks!

  23. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Jeff,

    No, that version was set for release today and it was too late to include the fix for this in it – sorry mate. :(

    While that’s not 100% necessary, you could send me a link to as hastebin or a Pastebin.

  24. 8 years, 1 month ago Private Message - Jeff Kyle

    This is a private message.

  25. 8 years, 1 month ago Alex S
    Hi, I Work Here

    Hi Jeff,

    Awesome – thanks mate! :)

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More