Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Router/common: Refactors and fixes the BrowserViewportScroller's scrolling behavior #40241

Closed
wants to merge 3 commits into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Dec 22, 2020

Refactors and fixes the BrowserViewportScroller's scrolling behavior.

Commit 1:
The BrowserViewportScroller injects but does not use the ErrorHandler.
This commit removes the ErrorHandler from the constructor.

Commit 2:
The current tests in the router scroller are
change-detector tests
and do not ensure the correct behavior of the scroller.
This commit updates the tests to assert actual scrolling behavior of the
browser.

Commit 3:
According to the spec,
we should attempt to set the browser focus after scrolling to a
fragment. Note that this change does not exactly follow the robust steps
outlined in the spec by finding a fallback target if the original is not
focusable. Instead, we simply attempt to focus the element by calling
focus on it, which will do nothing if the element is not focusable.

fixes #30067

@google-cla google-cla bot added the cla: yes label Dec 22, 2020
The `BrowserViewportScroller` injects but does not use the `ErrorHandler`.
This commit removes the `ErrorHandler` from the constructor.
The current tests in the router scroller are
[change-detector tests](https://testing.googleblog.com/2015/01/testing-on-toilet-change-detector-tests.html)
and do not ensure the correct behavior of the scroller.
This commit updates the tests to assert actual scrolling behavior of the
browser.
@atscott
Copy link
Contributor Author

atscott commented Dec 22, 2020

presubmit
global

@atscott atscott force-pushed the routerscroller branch 2 times, most recently from be21305 to bf363b4 Compare December 22, 2020 23:16
@ngbot ngbot bot added this to the Backlog milestone Dec 23, 2020
@atscott atscott changed the title Routerscroller Router/common: Refactors and fixes the BrowserViewportScroller's scrolling behavior Dec 28, 2020
@atscott atscott marked this pull request as ready for review December 28, 2020 16:49
@pullapprove pullapprove bot added the area: common Issues related to APIs in the @angular/common package label Dec 28, 2020
@atscott atscott added target: patch This PR is targeted for the next patch release action: review The PR is still awaiting reviews from at least one requested reviewer labels Dec 28, 2020
packages/common/src/viewport_scroller.ts Outdated Show resolved Hide resolved
packages/common/src/viewport_scroller.ts Outdated Show resolved Hide resolved
packages/common/src/viewport_scroller.ts Outdated Show resolved Hide resolved
According to the [spec](https://html.spec.whatwg.org/#scroll-to-fragid),
we should attempt to set the browser focus after scrolling to a
fragment. Note that this change does not exactly follow the robust steps
outlined in the spec by finding a fallback target if the original is not
focusable. Instead, we simply attempt to focus the element by calling
`focus` on it, which will do nothing if the element is not focusable.

fixes angular#30067
@atscott atscott added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Dec 29, 2020
josephperrott pushed a commit that referenced this pull request Jan 5, 2021
…#40241)

The `BrowserViewportScroller` injects but does not use the `ErrorHandler`.
This commit removes the `ErrorHandler` from the constructor.

PR Close #40241
josephperrott pushed a commit that referenced this pull request Jan 5, 2021
The current tests in the router scroller are
[change-detector tests](https://testing.googleblog.com/2015/01/testing-on-toilet-change-detector-tests.html)
and do not ensure the correct behavior of the scroller.
This commit updates the tests to assert actual scrolling behavior of the
browser.

PR Close #40241
josephperrott pushed a commit that referenced this pull request Jan 5, 2021
According to the [spec](https://html.spec.whatwg.org/#scroll-to-fragid),
we should attempt to set the browser focus after scrolling to a
fragment. Note that this change does not exactly follow the robust steps
outlined in the spec by finding a fallback target if the original is not
focusable. Instead, we simply attempt to focus the element by calling
`focus` on it, which will do nothing if the element is not focusable.

fixes #30067

PR Close #40241
josephperrott pushed a commit that referenced this pull request Jan 5, 2021
The current tests in the router scroller are
[change-detector tests](https://testing.googleblog.com/2015/01/testing-on-toilet-change-detector-tests.html)
and do not ensure the correct behavior of the scroller.
This commit updates the tests to assert actual scrolling behavior of the
browser.

PR Close #40241
josephperrott pushed a commit that referenced this pull request Jan 5, 2021
According to the [spec](https://html.spec.whatwg.org/#scroll-to-fragid),
we should attempt to set the browser focus after scrolling to a
fragment. Note that this change does not exactly follow the robust steps
outlined in the spec by finding a fallback target if the original is not
focusable. Instead, we simply attempt to focus the element by calling
`focus` on it, which will do nothing if the element is not focusable.

fixes #30067

PR Close #40241
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: common Issues related to APIs in the @angular/common package cla: yes target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

♿ Router: Focus element after URL hash scroll into view navigation
4 participants