Skip to content

fix(ChatInput): Page scrolls down to the chat input when a step loads - #2395

Open
Isaries wants to merge 1 commit into
WISE-Community:developfrom
Isaries:fix/chat-input-scrolls-page-on-load
Open

Isaries wants to merge 1 commit into
WISE-Community:developfrom
Isaries:fix/chat-input-scrolls-page-on-load

Conversation

@Isaries

@Isaries Isaries commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Every step that contains an AI Chat or Dialog Guidance component jumps down to the chat input as soon as it renders. ChatInputComponent focuses its textarea in ngAfterViewInit, and a plain focus() also scrolls the element into view, so the page skips past the prompt and any content placed above the chat, such as a reading passage or an HTML component.

Students land in the middle of the step and have to scroll back up to find what they are supposed to read first. On a long step the jump can be well over a screen. The same happens in Dialog Guidance when the input appears after the student picks an avatar.

Changes

  • focus({ preventScroll: true }), so the textarea still receives keyboard focus without moving the page. Browsers that do not support the option ignore it and behave as before.

Test

  • New case in chat-input.component.spec.ts: the textarea is focused with { preventScroll: true }. Against the current develop, it fails with Expected spy focus to have been called with: Expected $.length = 0 to equal 1. Expected $[0] = undefined to equal Object({ preventScroll: true }).
  • The existing focus test still passes.

ChatInputComponent focuses its textarea in ngAfterViewInit. A plain
focus() call also scrolls the textarea into view, so every step that
contains an AI Chat or Dialog Guidance component jumps down to the
input as soon as it renders, skipping past the prompt and any other
content above it.

Pass { preventScroll: true } to focus() so the textarea still receives
keyboard focus without moving the page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant