Commit af91b95f authored by Yura Zenevich's avatar Yura Zenevich
Browse files

Bug 1548842 - always try to center selected row when toggling audit filter. r=mtigley

Differential Revision: https://phabricator.services.mozilla.com/D29830

--HG--
extra : moz-landing-system : lando
parent 035996e0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ class AccessibilityTree extends Component {
    if (this.props.filtered !== prevProps.filtered) {
      const selected = document.querySelector(".treeTable .treeRow.selected");
      if (selected) {
        scrollIntoView(selected);
        scrollIntoView(selected, { center: true });
      }
    }

+8 −1
Original line number Diff line number Diff line
@@ -90,13 +90,15 @@ define(function(require, exports, module) {
   *          - alignTo:   "top" or "bottom" to indicate if we should scroll the element
   *                       to the top or the bottom of the scrollable container when the
   *                       element is off canvas.
   *          - center:    Indicate if we should scroll the element to the middle of the
   *                       scrollable container when the element is off canvas.
   */
  function scrollIntoView(element, options = {}) {
    if (!element) {
      return;
    }

    const { alignTo, container } = options;
    const { alignTo, center, container } = options;

    const { top, bottom } = element.getBoundingClientRect();
    const scrolledParent = closestScrolledParent(container || element.parentNode);
@@ -109,6 +111,11 @@ define(function(require, exports, module) {
      return;
    }

    if (center) {
      element.scrollIntoView({ block: "center" });
      return;
    }

    const scrollToTop = alignTo ?
      alignTo === "top" : !scrolledParentRect || top < scrolledParentRect.top;
    element.scrollIntoView(scrollToTop);