mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06:00
WebUI: Improve table overflow handling
This PR relies on flexbox to ensure all WebUI tables are the correct height without overflowing. Table headers are now always visible and JS-based dynamic resizing is no longer needed. PR #21652.
This commit is contained in:
committed by
GitHub
parent
b083029841
commit
dc30b9c2ec
@@ -100,33 +100,6 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||
tableDiv.addEventListener("scroll", () => {
|
||||
tableElement.style.left = `${-tableDiv.scrollLeft}px`;
|
||||
});
|
||||
|
||||
// if the table exists within a panel
|
||||
const parentPanel = tableDiv.getParent(".panel");
|
||||
if (parentPanel) {
|
||||
const resizeFn = (entries) => {
|
||||
const panel = entries[0].target;
|
||||
let h = panel.getBoundingClientRect().height - tableFixedHeaderDiv.getBoundingClientRect().height;
|
||||
tableDiv.style.height = `${h}px`;
|
||||
|
||||
// Workaround due to inaccurate calculation of elements heights by browser
|
||||
let n = 2;
|
||||
|
||||
// is panel vertical scrollbar visible or does panel content not fit?
|
||||
while (((panel.clientWidth !== panel.offsetWidth) || (panel.clientHeight !== panel.scrollHeight)) && (n > 0)) {
|
||||
--n;
|
||||
h -= 0.5;
|
||||
tableDiv.style.height = `${h}px`;
|
||||
}
|
||||
};
|
||||
|
||||
const resizeDebouncer = window.qBittorrent.Misc.createDebounceHandler(100, (entries) => {
|
||||
resizeFn(entries);
|
||||
});
|
||||
|
||||
const resizeObserver = new ResizeObserver(resizeDebouncer);
|
||||
resizeObserver.observe(parentPanel, { box: "border-box" });
|
||||
}
|
||||
},
|
||||
|
||||
setupHeaderEvents: function() {
|
||||
|
||||
@@ -205,10 +205,10 @@ window.qBittorrent.Search ??= (() => {
|
||||
|
||||
// unhide the results elements
|
||||
if (numSearchTabs() >= 1) {
|
||||
$("searchResultsNoSearches").style.display = "none";
|
||||
$("searchResultsFilters").style.display = "block";
|
||||
$("searchResultsTableContainer").style.display = "block";
|
||||
$("searchTabsToolbar").style.display = "block";
|
||||
$("searchResultsNoSearches").classList.add("invisible");
|
||||
$("searchResultsFilters").classList.remove("invisible");
|
||||
$("searchResultsTableContainer").classList.remove("invisible");
|
||||
$("searchTabsToolbar").classList.remove("invisible");
|
||||
}
|
||||
|
||||
// select new tab
|
||||
@@ -271,10 +271,10 @@ window.qBittorrent.Search ??= (() => {
|
||||
|
||||
$("numSearchResultsVisible").textContent = 0;
|
||||
$("numSearchResultsTotal").textContent = 0;
|
||||
$("searchResultsNoSearches").style.display = "block";
|
||||
$("searchResultsFilters").style.display = "none";
|
||||
$("searchResultsTableContainer").style.display = "none";
|
||||
$("searchTabsToolbar").style.display = "none";
|
||||
$("searchResultsNoSearches").classList.remove("invisible");
|
||||
$("searchResultsFilters").classList.add("invisible");
|
||||
$("searchResultsTableContainer").classList.add("invisible");
|
||||
$("searchTabsToolbar").classList.add("invisible");
|
||||
}
|
||||
else if (isTabSelected && newTabToSelect) {
|
||||
setActiveTab(newTabToSelect);
|
||||
@@ -670,9 +670,9 @@ window.qBittorrent.Search ??= (() => {
|
||||
|
||||
const searchPluginsEmpty = (searchPlugins.length === 0);
|
||||
if (!searchPluginsEmpty) {
|
||||
$("searchResultsNoPlugins").style.display = "none";
|
||||
$("searchResultsNoPlugins").classList.add("invisible");
|
||||
if (numSearchTabs() === 0)
|
||||
$("searchResultsNoSearches").style.display = "block";
|
||||
$("searchResultsNoSearches").classList.remove("invisible");
|
||||
|
||||
// sort plugins alphabetically
|
||||
const allPlugins = searchPlugins.sort((left, right) => {
|
||||
|
||||
Reference in New Issue
Block a user