Skip to content

Commit

Permalink
fix hash scrolling on first render
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarmil committed Nov 18, 2023
1 parent 7626b1b commit 49b9d02
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/Bolero/Components.fs
Original file line number Diff line number Diff line change
Expand Up @@ -231,22 +231,19 @@ and [<AbstractClass>]
| None -> initModel, []

override this.OnAfterRenderAsync(firstRender) =
if firstRender then
runProgramLoop()
if router.IsSome then
this.NavigationInterception.EnableNavigationInterceptionAsync()
else
Task.CompletedTask
else
task {
if firstRender then
runProgramLoop()
if router.IsSome then
do! this.NavigationInterception.EnableNavigationInterceptionAsync()

match routeHash with
| None ->
Task.CompletedTask
| None -> ()
| Some h ->
routeHash <- None
task {
let! elt = this.JSRuntime.InvokeAsync<IJSObjectReference>("document.getElementById", h)
return! elt.InvokeVoidAsync("scrollIntoView")
}
let! elt = this.JSRuntime.InvokeAsync<IJSObjectReference>("document.getElementById", h)
return! elt.InvokeVoidAsync("scrollIntoView")
}

override this.Render() =
view
Expand Down

0 comments on commit 49b9d02

Please sign in to comment.