From 548ae3eb98146b446187e8aec13de7979e7edc0c Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 28 Oct 2021 15:42:31 +0800 Subject: [PATCH] Make commit-statuses popup show correctly (#17447) (#17466) Backport #17447 Close #17443 --- web_src/js/index.js | 5 ++++- web_src/less/_repository.less | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/web_src/js/index.js b/web_src/js/index.js index ec9df29e74..aa684b0467 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -788,10 +788,13 @@ async function initRepository() { // Commit statuses $('.commit-statuses-trigger').each(function () { + const positionRight = $('.repository.file.list').length > 0 || $('.repository.diff').length > 0; + const popupPosition = positionRight ? 'right center' : 'left center'; $(this) .popup({ on: 'click', - position: ($('.repository.file.list').length > 0 ? 'right center' : 'left center'), + lastResort: popupPosition, // prevent error message "Popup does not fit within the boundaries of the viewport" + position: popupPosition, }); }); diff --git a/web_src/less/_repository.less b/web_src/less/_repository.less index ba6f19617c..993b7f5be2 100644 --- a/web_src/less/_repository.less +++ b/web_src/less/_repository.less @@ -1,6 +1,19 @@ .repository { - .commit-statuses .list > .item { - line-height: 2; + .popup.commit-statuses { + // we had better limit the max size of the popup, and add scroll bars if the content size is too large. + // otherwise some part of the popup will be hidden by viewport boundary + max-height: 45vh; + max-width: 60vw; + overflow: auto; + padding: 0; + + .list { + padding: .8em; // to make the scrollbar align to the border, we move the padding from outer `.popup` to this inside `.list` + + > .item { + line-height: 2; + } + } } .repo-header { -- 2.39.5