Repository navigation
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every step that contains an AI Chat or Dialog Guidance component jumps down to the chat input as soon as it renders.
ChatInputComponentfocuses its textarea inngAfterViewInit, and a plainfocus()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
chat-input.component.spec.ts: the textarea is focused with{ preventScroll: true }. Against the currentdevelop, it fails withExpected spy focus to have been called with: Expected $.length = 0 to equal 1. Expected $[0] = undefined to equal Object({ preventScroll: true }).