diff --git a/apps/client/src/widgets/attribute_widgets/attribute_detail.ts b/apps/client/src/widgets/attribute_widgets/attribute_detail.ts index 9017673f3..9b66aa6f9 100644 --- a/apps/client/src/widgets/attribute_widgets/attribute_detail.ts +++ b/apps/client/src/widgets/attribute_widgets/attribute_detail.ts @@ -295,6 +295,7 @@ interface AttributeDetailOpts { x: number; y: number; focus?: "name"; + parent?: HTMLElement; } interface SearchRelatedResponse { @@ -560,19 +561,22 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget { this.toggleInt(true); - const offset = this.parent?.$widget.offset() || { top: 0, left: 0 }; + const offset = this.parent?.$widget?.offset() || { top: 0, left: 0 }; const detPosition = this.getDetailPosition(x, offset); const outerHeight = this.$widget.outerHeight(); const height = $(window).height(); - if (detPosition && outerHeight && height) { - this.$widget - .css("left", detPosition.left) - .css("right", detPosition.right) - .css("top", y - offset.top + 70) - .css("max-height", outerHeight + y > height - 50 ? height - y - 50 : 10000); + if (!detPosition || !outerHeight || !height) { + console.warn("Can't position popup, is it attached?"); + return; } + this.$widget + .css("left", detPosition.left) + .css("right", detPosition.right) + .css("top", y - offset.top + 70) + .css("max-height", outerHeight + y > height - 50 ? height - y - 50 : 10000); + if (focus === "name") { this.$inputName.trigger("focus").trigger("select"); } diff --git a/apps/client/src/widgets/note_list.ts b/apps/client/src/widgets/note_list.ts index 1b00bd8c2..74602c921 100644 --- a/apps/client/src/widgets/note_list.ts +++ b/apps/client/src/widgets/note_list.ts @@ -3,8 +3,6 @@ import NoteListRenderer from "../services/note_list_renderer.js"; import type FNote from "../entities/fnote.js"; import type { CommandListener, CommandListenerData, CommandMappings, CommandNames, EventData, EventNames } from "../components/app_context.js"; import type ViewMode from "./view_widgets/view_mode.js"; -import AttributeDetailWidget from "./attribute_widgets/attribute_detail.js"; -import { Attribute } from "../services/attribute_parser.js"; const TPL = /*html*/`