diff --git a/packages/comment-widget/src/base-form.ts b/packages/comment-widget/src/base-form.ts index 41ffbb2..9ae96dd 100644 --- a/packages/comment-widget/src/base-form.ts +++ b/packages/comment-widget/src/base-form.ts @@ -223,6 +223,10 @@ export class BaseForm extends LitElement { form?.reset(); } + setFocus() { + this.textareaRef.value?.focus(); + } + static override styles = [ varStyles, baseStyles, diff --git a/packages/comment-widget/src/reply-form.ts b/packages/comment-widget/src/reply-form.ts index 3c0ce18..be1e416 100644 --- a/packages/comment-widget/src/reply-form.ts +++ b/packages/comment-widget/src/reply-form.ts @@ -38,6 +38,15 @@ export class ReplyForm extends LitElement { baseFormRef: Ref = createRef(); + override connectedCallback(): void { + super.connectedCallback(); + + setTimeout(() => { + this.scrollIntoView({ block: 'center', inline: 'start', behavior: 'smooth' }); + this.baseFormRef.value?.setFocus(); + }, 0); + } + override render() { return html``; }