Sitecore 8 Experience Editor – Edit Component Properties causes page to jumps to top

Another quick blog post for a fairly minor bug but causes a big annoyance for the content editors.

I tend to use Rendering Parameters a fair amount, it’s a really neat way of making controls more flexible and customisable without duplicating work, making it much easier for editors. But in all versions of Sitecore 8 I have worked with (update 2 to 5) whenever you click “Edit Component Properties” the Control Properties modal opens up correctly but you also jump to the top of the page:

sc8-edit-component-properties

When you have a long page that breaks the editing flow, making the users have to scroll to find their position again. If they were making a design change like a CSS class/styling option then you have to scroll back down, if it’s the wrong one then click again, change, scroll back down…

So, annoying and a time waster.

I finally got annoyed by it enough, and a fact we are at update-5 and the bug still exists, that I went ahead and figured out the fix.

The Simple Fix

In a text editor open up: /sitecore/shell/Applications/Page Modes/ChromeControls.js

On line 214, within renderCommandTag function add: e.stop();

This stops event propagation and the default action triggering. http://api.prototypejs.org/dom/Event/stop/

The outline of the function should look similar to this now:

  renderCommandTag: function(command, chrome, isMoreCommand /*Defines if commnad appears in 'More' dropDown*/) {
    ...

    if (command.click.indexOf("chrome:") == 0) {
      var click = Sitecore.PageModes.Utility.parseCommandClick(command.click);
      if (command.type == "common") {
        tag.click(function(e) {
          e.stop();   /* ADD THIS TO STOP EVENT PROPAGATION */
          Sitecore.PageModes.ChromeManager.setCommandSender(chrome);
          Sitecore.PageModes.ChromeManager.handleCommonCommands(chrome, click.message, click.params);
        });
      }
      else {
        ...
      }
    }
    else if (command.click.indexOf("javascript:") == 0) {      
      ...
    }
    else {
      ...
    }

    return tag;
  },

That should make your editors happier 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s