Add 'scrollIntoView' to baseUIElement, autoscroll questions into view when appropriate

This commit is contained in:
Pieter Vander Vennet 2022-12-06 03:43:54 +01:00
parent aec5ffba79
commit 9e97eba519
4 changed files with 78 additions and 13 deletions

View file

@ -33,6 +33,8 @@ export default class QuestionBox extends VariableUiElement {
.filter((tr) => tr.question !== undefined)
.filter((tr) => tr.question !== null)
let focus: () => void = () => {};
const tagRenderingQuestions = tagRenderings.map(
(tagRendering, i) =>
new Lazy(
@ -42,6 +44,7 @@ export default class QuestionBox extends VariableUiElement {
afterSave: () => {
// We save and indicate progress by pinging and recalculating
skippedQuestions.ping()
focus()
},
cancelButton: Translations.t.general.skip
.Clone()
@ -49,6 +52,8 @@ export default class QuestionBox extends VariableUiElement {
.onClick(() => {
skippedQuestions.data.push(i)
skippedQuestions.ping()
focus()
}),
})
)
@ -136,5 +141,8 @@ export default class QuestionBox extends VariableUiElement {
this.skippedQuestions = skippedQuestions
this.restingQuestions = questionsToAsk
focus = () => this.ScrollIntoView({
onlyIfPartiallyHidden: true
})
}
}