Pārlūkot izejas kodu

HUE-4951 [assist] Scroll to column data in sample popup can be incorrect

Enrico Berti 9 gadi atpakaļ
vecāks
revīzija
4efcb8d

+ 12 - 4
desktop/core/src/desktop/static/desktop/js/jquery.huedatatable.js

@@ -237,10 +237,10 @@
     self.isDrawing = false;
 
     self.fnDraw = function (force) {
-      if (!self.isDrawing) {
+      var aoColumns = self.$table.data('aoColumns');
+      if (!self.isDrawing && aoColumns) {
         self.isDrawing = true;
         var $t = self.$table;
-        var aoColumns = self.$table.data('aoColumns');
         var data = self.$table.data('data');
         var appendable = $t.children('tbody').length > 0 ? $t.children('tbody') : $t;
         var startCol = -1;
@@ -334,11 +334,19 @@
           }
           if ($t.data('scrollAnimate')) {
             $t.parent().animate({
-              scrollLeft: colSel.position().left + $t.parent().scrollLeft() - $t.parent().offset().left - 30
+              scrollLeft: colSel.position().left + $t.parent().scrollLeft() - ($t.data('scrollInPopover') ? 0 : $t.parent().offset().left) - 30
             }, 300, function () {
               $t.parent().trigger('scroll');
             });
-            $t.data('scrollAnimate', null);
+            if ($t.data('scrollLastColPosLeft') == null || $t.data('scrollLastColPosLeft') != colSel.position().left) {
+              $t.data('scrollLastColPosLeft', colSel.position().left);
+              $t.data('scrollLastParentLeft', $t.parent().scrollLeft());
+            }
+            else {
+              $t.data('scrollAnimate', null);
+              $t.data('scrollLastColPosLeft', null);
+              $t.data('scrollLastParentLeft', null);
+            }
           }
           if ($t.data('scrollToRow') == null) {
             colSel.addClass("columnSelected");

+ 1 - 0
desktop/core/src/desktop/templates/sql_context_popover.mako

@@ -654,6 +654,7 @@ from metadata.conf import has_navigator
                 _t.data('scrollToCol', _col.index());
                 _t.data('scrollToRow', null);
                 _t.data('scrollAnimate', true);
+                _t.data('scrollInPopover', true);
                 _t.parent().trigger('scroll');
               });
             }