Fix auto scroll to wait until discussion is loaded

fixes VICE-2435

Test Plan
1. Load a discussion in Legacy Discussions
2. Find a discussion ID (Hint: The ID is in the HTML)
3. Appnd #entry-NNNN (Your ID) to the URL and load
4. Expected: Page should auto scroll to entry when loaded
5. Now delete $entry-NNNN frmo the URL
6. Append /entry-NNNN and hit enter
7: Expected: Page should auto scroll to entry when loaded like Step 4

Change-Id: I74c661743a9b6cc1ada7292087282cd7293f1193
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/285760
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jason Gillett <jason.gillett@instructure.com>
Product-Review: Jason Gillett <jason.gillett@instructure.com>
QA-Review: Chawn Neal <chawn.neal@instructure.com>
This commit is contained in:
Jeffrey Johnson 2022-02-22 16:54:13 -08:00
parent 779e1377cd
commit 117602ab88
1 changed files with 9 additions and 1 deletions

View File

@ -216,7 +216,15 @@ ready(() => {
$container.one('scroll', () => router.navigate(''))
}, 10)
})
router.route('entry-:id', 'id', entriesView.goToEntry.bind(entriesView))
router.route('entry-:id', 'id', () => {
// Interval to deffer scrollng until page is fully loaded
const goToEntryIntervalId = setInterval( () => {
if(document.readyState === 'complete') {
entriesView.goToEntry.bind(entriesView)
clearInterval(goToEntryIntervalId)
}
}, 500)
})
router.route('page-:page', 'page', page => {
entriesView.render(page)
// TODO: can get a little bouncy when the page isn't as tall as the previous