Ensure scroll posotion resets to top when logo clicked #4328
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.
What does this change?
This PR fixes a regression introduced through a combination of PRs that removed ambiguity regarding the 'nonFree' parameter in the current search context. Previously when the logo was clicked the search returned to the top of the page i.e. positionTop = 0 - the code was recording the position of the scroll when the logo was clicked but the setting of nonFree to undefined ensured that the contexts did not match and thus the scroll was no reset to its previous location.
The introduction of typescript react contros has made the use of nonFree = undefined problematic as typescript won't accept that value for a boolean so we have had to do introduce some code changes to ensure both scrolling and page navigation work correctly by removing the ambiguity of nonFree = false/undefined - in some areas the code relied on these being equivalent and in others it required them to be treated as different - e.g. resetting scroll position.
The recent PR to fix issues around page to page navigation and providing correct nonFree values to typescript controls removed further ambiguity around the nonFree parameter such that during logo click process the contexts evaluate as equal and thus the scroll position was reset to its previous value rather than being left at page-top.
The removal of the ambiguity around nonFree is required for other navigations to operate correctly with the typescript controls and so this PR introduces a new function for the scroll service to allow user to say 'reset to top' - this function is called during the logo click process and ensure that positionTop is set to 0 and thus when the contexts evaluate to equal the reset scroll position is now top.
How should a reviewer test this change?
Ensure that on logo click the page resets to the top of the image list.
Who should look at this?
Tested? Documented?