Skip to content

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

Merged
hirokiterashima merged 1 commit into
WISE-Community:developfrom
Isaries:fix/chat-input-scrolls-page-on-load
Nov 23, 2026
Merged

hirokiterashima merged 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.
@hirokiterashima hirokiterashima self-assigned this Nov 23, 2026

@hirokiterashima hirokiterashima left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the catch&fix.

@hirokiterashima
hirokiterashima merged commit 0593231 into WISE-Community:develop Nov 23, 2026
3 of 4 checks passed
@hirokiterashima hirokiterashima added the bug Something isn't working label Nov 23, 2026
@hirokiterashima

Copy link
Copy Markdown
Member

🎉 This PR is included in version 5.252.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants