瀏覽代碼

HUE-7737 [frontend] Make sure popovers are aligned when opened the first time

Johan Ahlen 8 年之前
父節點
當前提交
90df79d
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

+ 8 - 2
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -1182,11 +1182,17 @@
                 ko.applyBindings(viewModel, $tip.get(0));
                 $tip.find(".close-popover").click(hidePopover);
                 if (options.minWidth) {
-                  $(".popover:visible").css('min-width', options.minWidth)
+                  var heightBefore = $tip.height();
+                  $tip.css('min-width', options.minWidth);
+                  // The width might affect the height in which case we need to reposition the popover
+                  var diff = (heightBefore - $tip.height()) / 2;
+                  if (diff !== 0) {
+                    $tip.css('top', ($tip.position().top + diff) + 'px');
+                  }
                 }
                 $content.empty();
                 $title.empty();
-                $(document).on('click', hideOnClickOutside)
+                $(document).on('click', hideOnClickOutside);
                 visible = true;
               }
             }, $title.get(0), 'replaceChildren');