1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Layout: Improved sidebar sizing, and dropdown consideration

- Updated tri-layout sidebars to have less padding and to avoid cutting
  off content when in single-sidebar mode.
- Updated dropdown handling to consider the parent scroll container when
  deciding to drop upwards, to help prevent cut-off.
This commit is contained in:
Dan Brown
2025-06-30 13:19:45 +01:00
parent dfeca246a0
commit 6045aff33a
3 changed files with 25 additions and 3 deletions

View File

@ -256,4 +256,22 @@ export function findTargetNodeAndOffset(parentNode: HTMLElement, offset: number)
export function hashElement(element: HTMLElement): string {
const normalisedElemText = (element.textContent || '').replace(/\s{2,}/g, '');
return cyrb53(normalisedElemText);
}
/**
* Find the closest scroll container parent for the given element
* otherwise will default to the body element.
*/
export function findClosestScrollContainer(start: HTMLElement): HTMLElement {
let el: HTMLElement|null = start;
do {
const computed = window.getComputedStyle(el);
if (computed.overflowY === 'scroll') {
return el;
}
el = el.parentElement;
} while (el);
return document.body;
}