This commit is contained in:
Vanessa 2023-09-01 21:35:44 +08:00
parent c61161615f
commit c7cc5e6510
2 changed files with 6 additions and 5 deletions

View file

@ -56,14 +56,14 @@ export class Menu {
}
public showSubMenu(subMenuElement: HTMLElement) {
const parentRect = subMenuElement.parentElement.getBoundingClientRect();
subMenuElement.style.top = (parentRect.top - 8) + "px";
subMenuElement.style.left = (parentRect.right + 8) + "px";
const itemRect = subMenuElement.parentElement.getBoundingClientRect();
subMenuElement.style.top = (itemRect.top - 8) + "px";
subMenuElement.style.left = (itemRect.right + 8) + "px";
subMenuElement.style.bottom = "auto";
const rect = subMenuElement.getBoundingClientRect();
if (rect.right > window.innerWidth) {
if (parentRect.left - 8 > rect.width) {
subMenuElement.style.left = (parentRect.left - 8 - rect.width) + "px";
if (itemRect.left - 8 > rect.width) {
subMenuElement.style.left = (itemRect.left - 8 - rect.width) + "px";
} else {
subMenuElement.style.left = (window.innerWidth - rect.width) + "px";
}

View file

@ -630,6 +630,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
event.preventDefault();
break;
} else if (target.id === "searchFilter") {
window.siyuan.menus.menu.remove();
filterMenu(config, () => {
config.page = 1;
inputEvent(element, config, undefined, edit, true);