Sitecore Content tree scroll to top in Firefox

2019-07-17 16:19发布

问题:

When I expand the Sitecore content tree and when the vertical scroll bar appears for the content tree, and if I scroll down and select an item in the bottom of the tree, it scroll to top. This only happens in Firefox, IE10, IE9, Chrome it works fine. I did the Sitecore upgrade very recently. Has anyone encountered similar issue? Please help!

Sitecore.NET 6.6.0 (rev. 130404)
Firefox versions - 21,22

回答1:

I have had a similar issue and contacted Sitecore support about it. They provided me with the following solution that works for us:
- open \sitecore\shell\Controls\Gecko.js
- replace at line 668

scBrowser.prototype.resizeFixsizeElements = function() {
  var form = $$("form")[0];

  this.fixsizeElements.each(function(element) {
    var height = form.getHeight() - element.scHeightAdjustment + "px";
    element.setStyle({ height: height });
  });

  /* trigger re-layouting to fix the firefox bug: table is not shrinking itself down on resize */
  scGeckoRelayout();
}

by:

scBrowser.prototype.resizeFixsizeElements = function() {
  var form = $$("form")[0];
  if (!form) {
    return;
  }

  this.fixsizeElements.each(function (element) {
    if (!element.hasClassName('scFixSizeNested')) {
      element.setStyle({ height: '100%' });
    }
  });

  var maxHeight = 0;
  var formChilds = form.childNodes;

  for (var i = 0; i != formChilds.length; i++) {
    var elementHeight = formChilds[i].offsetHeight;
    if (elementHeight > maxHeight) {
      maxHeight = elementHeight;
    }
  }

  var formHeight = form.offsetHeight;

  this.fixsizeElements.each(function (element) {
      var height = element.hasClassName('scFixSizeNested')
        ? (form.getHeight() - element.scHeightAdjustment) + 'px'
        : (element.offsetHeight - (maxHeight - formHeight)) + 'px';
      element.setStyle({ height: height });
  });

  /* trigger re-layouting to fix the firefox bug: table is not shrinking itself down on resize */
  scGeckoRelayout();
}


回答2:

Thanks to Sitecore support, found the issue, The issue occures due to Fixefox refreshes html controls as soon as some property was changed. Upon selecting an item, a content tree panels width is changed and as a result it is redrawn. Developed workaround forbids changing of the controls size for static controls for Firefox (like content tree). An aftermath might be incorrect window resizing (changing height of the browser window) in Firefox. To implement the workaround please replace an exicting one under the path 'Website\sitecore\shell\Controls\Gecko.js' with attached one and clear browser cache. Please notify us with the results.

scBrowser.prototype.resizeFixsizeElements = function() {
  var form = $$("form")[0];
  if (!form) {
    return;
  }
  if (!this.isFirefox)
    {
      this.fixsizeElements.each(function (element) {
        if (!element.hasClassName('scFixSizeNested')) {
          element.setStyle({ height: '100%' });
        }
      });        
       var maxHeight = 0;
  var formChilds = form.childNodes;

  for (var i = 0; i != formChilds.length; i++) {
    var elementHeight = formChilds[i].offsetHeight;
    if (elementHeight > maxHeight) {
      maxHeight = elementHeight;
    }
  }
  var formHeight = form.offsetHeight;
  this.fixsizeElements.each(function (element) {
      var height = element.hasClassName('scFixSizeNested')
        ? (form.getHeight() - element.scHeightAdjustment) + 'px'
        : (element.offsetHeight - (maxHeight - formHeight)) + 'px';
      element.setStyle({ height: height });
  });   
}
  /* trigger re-layouting to fix the firefox bug: table is not shrinking itself down on resize */
  scGeckoRelayout();
}


标签: sitecore