Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): input not automatically focused (#10050)

akumatus9ca2133e34aa
diff --git a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/components/add-popover.ts b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/components/add-popover.ts
index 7c43624e7b..502f102ffc 100644
--- a/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/components/add-popover.ts
+++ b/packages/frontend/core/src/blocksuite/presets/ai/chat-panel/components/add-popover.ts
@@ -7,7 +7,7 @@ import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/utils';
import { SearchIcon } from '@blocksuite/icons/lit';
import type { DocMeta } from '@blocksuite/store';
import { css, html } from 'lit';
-import { property, state } from 'lit/decorators.js';
+import { property, query, state } from 'lit/decorators.js';
import type { DocSearchMenuConfig } from '../chat-config';
import type { ChatChip } from '../chat-context';
@@ -93,11 +93,20 @@ export class ChatPanelAddPopover extends SignalWatcher(
@property({ attribute: false })
accessor abortController!: AbortController;
+ @query('.search-input')
+ accessor searchInput!: HTMLInputElement;
+
override connectedCallback() {
super.connectedCallback();
this._updateDocGroup();
}
+ override firstUpdated() {
+ requestAnimationFrame(() => {
+ this.searchInput.focus();
+ });
+ }
+
override render() {
const items = Array.isArray(this._docGroup.items)
? this._docGroup.items