fix
This commit is contained in:
@@ -98,6 +98,17 @@ const getSidebarWidthFromRoot = () => {
|
||||
return Number.isFinite(parsed) ? parsed : null;
|
||||
};
|
||||
|
||||
const shouldSuppressSidebarForDetailWidth = (detailWidth) => {
|
||||
if (!isBrowser || !Number.isFinite(detailWidth)) {
|
||||
return false;
|
||||
}
|
||||
const sidebarWidth = getSidebarWidthFromRoot() || 0;
|
||||
const minMainContentWidth = window.innerWidth / 3;
|
||||
const occupiedWidth = detailWidth + sidebarWidth;
|
||||
const availableWidth = window.innerWidth - occupiedWidth;
|
||||
return availableWidth < minMainContentWidth;
|
||||
};
|
||||
|
||||
export const createDocumentViewerHeaderActions = ({
|
||||
document,
|
||||
actionState,
|
||||
@@ -343,15 +354,7 @@ const DocumentViewerPanel = ({
|
||||
const panelWidth = pendingWidthRef.current
|
||||
?? detailPanelWidth
|
||||
?? panelRef.current?.getBoundingClientRect().width;
|
||||
const sidebarWidth = getSidebarWidthFromRoot();
|
||||
if (!Number.isFinite(panelWidth)) {
|
||||
setSidebarSuppressed(false);
|
||||
return;
|
||||
}
|
||||
const minMainContentWidth = (window.innerWidth * 2) / 5;
|
||||
const occupiedWidth = panelWidth + (Number.isFinite(sidebarWidth) ? sidebarWidth : 0);
|
||||
const availableWidth = window.innerWidth - occupiedWidth;
|
||||
setSidebarSuppressed(availableWidth < minMainContentWidth);
|
||||
setSidebarSuppressed(shouldSuppressSidebarForDetailWidth(panelWidth));
|
||||
};
|
||||
|
||||
updateSuppression();
|
||||
@@ -414,8 +417,8 @@ const DocumentViewerPanel = ({
|
||||
if (clamped != null) {
|
||||
pendingWidthRef.current = clamped;
|
||||
applyDetailPanelWidth(clamped);
|
||||
if (isSidebarVariant && isBrowser) {
|
||||
setSidebarSuppressed(clamped > window.innerWidth / 2);
|
||||
if (isSidebarVariant) {
|
||||
setSidebarSuppressed(shouldSuppressSidebarForDetailWidth(clamped));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user