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
Fix aio minor fixes #21695
Fix aio minor fixes #21695
Conversation
You can preview 17bbc2f at https://pr21695-17bbc2f.ngbuilds.io/. |
@@ -74,7 +74,6 @@ | |||
}, | |||
|
|||
{ | |||
"url": "tutorial", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
await newDocPromise; // Wait for the new document to be fetched. | ||
fixture.detectChanges(); // Propagate document change to the view (i.e to `DocViewer`). | ||
await docRenderedPromise; // Wait for the `docRendered` event. | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice helper!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why use
const awaitDocRendered = async () => { ... };
rather than
async function awaitDocRendered() { ... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because function
is noso ES5 😛
(The real answer is that I was keeping consistent with what we had before: const initializeTest = () => {
. Changed to function
😁)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Updated the previous comment 😒)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😺
aio/src/app/app.component.spec.ts
Outdated
await docRenderedPromise; // Wait for the `docRendered` event. | ||
}; | ||
|
||
const initializeTest = (waitForDoc = true) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly here, why not: function initializeText(waitForDoc = true) { ... }
?
|
||
initializeTest(); | ||
initializeTest(false); | ||
jasmine.clock().tick(1); // triggers the HTTP response for the document |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you using jasmine clocks here because the animations can't be tested using fakeAsync
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't recall tbh. I think the main reason was that fakeAsync()
barks on pending timeouts (and we have a bunch on them in AppComponent
), so you have to flush unrelated timeouts all the time.
I generally find jasmine clocks to work fine for these simple things (e.g. not interested in microtasks, etc). But I am pretty sure fakeAsync()
would work as well (with some extra flushing/ticking at the end of each test).
Another issue with fakeAsync
is that you shouldn't have async stuff (e.g. timers) going on outside of fakeAsync
, so it is difficult to share beforeEach
blocks with tests that don't use fakeAsync()
(but I don't think this affects us in this particular case).
return of(data); | ||
|
||
// Preserve async nature of `HttpClient`. | ||
return timer(1).mapTo(data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@@ -57,9 +57,11 @@ export class AppComponent implements OnInit { | |||
@HostBinding('class') | |||
hostClasses = ''; | |||
|
|||
isFetching = false; | |||
// Disable all Angular animations for the initial render. | |||
@HostBinding('@.disabled') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sneaky
aio/src/app/app.component.ts
Outdated
if (this.isStarting) { | ||
// In order to ensure that the initial sidenav-content left margin | ||
// adjustment happens without animation, we need to ensure that | ||
// `isStarting` remain `true` until the margin change is triggered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remain -> remains
.starting.mat-sidenav-transition { | ||
.mat-sidenav, | ||
.mat-sidenav-content, | ||
.mat-sidenav-backdrop.mat-sidenav-shown { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So has the behaviour of Angular Material changed, so that only the drawer
is animated now? Or were we wrong previously about this, and were capturing all these elements to block their animation to make up for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the Material styles have changed so that the transition (which we want to overwrite here) is on .mat-drawer-content
: angular/components@372436c#diff-20a207a17a517c2beae586b174bf14b7L4
(We could probably keep the previous classes .mat-sidenav-transition
/.mat-sidenav-content
, since they are present on the element too, but it felt safer to match the Material selectors.)
The .mat-sidenav
animation has been switched to @angular/animations
for a while now, so these CSS styles didn't have any effect.
Finally, the backdrop is only visible on narrow screen where we don't have the sidenav and content side-by-side, but the sidenav is always closed on these narrow screens (even when landing on sidenav page), so the backdrop was never shown anyway.
.mat-icon, .material-icons { | ||
visibility: hidden; | ||
display: inline-block; | ||
.header-link { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit that contains this change appears to have the wrong commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a typo, a commit message that needs changing and a few questions.
17bbc2f
to
4d1ec60
Compare
You can preview 4d1ec60 at https://pr21695-4d1ec60.ngbuilds.io/. |
Thx for the review, @petebacondarwin. |
Hm...something does not look right when loading the home page (there is white margin on the left briefly). |
You can preview 4b61c69 at https://pr21695-4b61c69.ngbuilds.io/. |
Looks much better now. One test fails on Travis (although it passes locally 😒). |
At least it is a clear error message.
|
Testing locally here... |
Works locally for me too :-/ |
It is an random error. It happened 3/4 times on Travis. Related: angular/protractor#3093 |
You can preview 338e144 at https://pr21695-338e144.ngbuilds.io/. |
Implemented @Maxkorz's [suggestion](#21515 (comment)). Fixes #21515 PR Close #21695
Navigating to a document while trying to expand or collapse a sub-menu is undesirable and confusing. All sub-menu toggles should have no other effect than expanding/collapsing the corresponding sub-menu. PR Close #21695
Previously, the mocked `HttpClient` was synchronous in tests (despite the actual `HttpClient` being asynchronous). Although we use observables (which generally make the implementation sync/async-agnostic), the fact that we have no control over when Angular updates/checks views and calls lifecycle hooks resulted in different behavior (and errors) in tests (with sync `HttpClient`) vs actual app (with async `HttpClient`). This commit ensures that the behavior (and errors) are consistent between the tests and the actual app by making the mocked `HttpClient` asynchronous. PR Close #21695
For the initial rendering, where there is no transition from a previous visual state to a new one, animations make little sense. The page should load with as few reflows as possible. Similarly, while we typically want to defer updating the SideNav state (e.g. opened/closed) until the "leaving" document is animated out of the page, on the initial rendering (where there is no "leaving" document) this leads to the SideNav flashing (from closed to open). These worked as expected before, but several parts (mostly related to documents with a SideNav) have been accidentally broken in recent commits (e.g. when upgraded to latest material, or enabled animations for DocViewer transitions, etc.). This commit restores the previous behavior by ensuring that (on the initial rendering) the SideNav state is updated as soon as possible and that there will be no animations when: 1. The hamburger button appears. 2. The SideNav is opened. 3. The main section's width is adjusted to make room for the SideNav. PR Close #21695
During the initial load of the page (probably until the icon styles are loaded and/or applied), the `.header-link` element is wider, pushing the heading text slightly to the right (for a brief moment). This commit prevents this slight shift by explicitly setting the width for the `.header-link` element. PR Close #21695
Implemented @Maxkorz's [suggestion](#21515 (comment)). Fixes #21515 PR Close #21695
Navigating to a document while trying to expand or collapse a sub-menu is undesirable and confusing. All sub-menu toggles should have no other effect than expanding/collapsing the corresponding sub-menu. PR Close angular#21695
…#21695) Previously, the mocked `HttpClient` was synchronous in tests (despite the actual `HttpClient` being asynchronous). Although we use observables (which generally make the implementation sync/async-agnostic), the fact that we have no control over when Angular updates/checks views and calls lifecycle hooks resulted in different behavior (and errors) in tests (with sync `HttpClient`) vs actual app (with async `HttpClient`). This commit ensures that the behavior (and errors) are consistent between the tests and the actual app by making the mocked `HttpClient` asynchronous. PR Close angular#21695
…1695) For the initial rendering, where there is no transition from a previous visual state to a new one, animations make little sense. The page should load with as few reflows as possible. Similarly, while we typically want to defer updating the SideNav state (e.g. opened/closed) until the "leaving" document is animated out of the page, on the initial rendering (where there is no "leaving" document) this leads to the SideNav flashing (from closed to open). These worked as expected before, but several parts (mostly related to documents with a SideNav) have been accidentally broken in recent commits (e.g. when upgraded to latest material, or enabled animations for DocViewer transitions, etc.). This commit restores the previous behavior by ensuring that (on the initial rendering) the SideNav state is updated as soon as possible and that there will be no animations when: 1. The hamburger button appears. 2. The SideNav is opened. 3. The main section's width is adjusted to make room for the SideNav. PR Close angular#21695
During the initial load of the page (probably until the icon styles are loaded and/or applied), the `.header-link` element is wider, pushing the heading text slightly to the right (for a brief moment). This commit prevents this slight shift by explicitly setting the width for the `.header-link` element. PR Close angular#21695
…lar#21695) Implemented @Maxkorz's [suggestion](angular#21515 (comment)). Fixes angular#21515 PR Close angular#21695
Navigating to a document while trying to expand or collapse a sub-menu is undesirable and confusing. All sub-menu toggles should have no other effect than expanding/collapsing the corresponding sub-menu. PR Close angular#21695
…#21695) Previously, the mocked `HttpClient` was synchronous in tests (despite the actual `HttpClient` being asynchronous). Although we use observables (which generally make the implementation sync/async-agnostic), the fact that we have no control over when Angular updates/checks views and calls lifecycle hooks resulted in different behavior (and errors) in tests (with sync `HttpClient`) vs actual app (with async `HttpClient`). This commit ensures that the behavior (and errors) are consistent between the tests and the actual app by making the mocked `HttpClient` asynchronous. PR Close angular#21695
…1695) For the initial rendering, where there is no transition from a previous visual state to a new one, animations make little sense. The page should load with as few reflows as possible. Similarly, while we typically want to defer updating the SideNav state (e.g. opened/closed) until the "leaving" document is animated out of the page, on the initial rendering (where there is no "leaving" document) this leads to the SideNav flashing (from closed to open). These worked as expected before, but several parts (mostly related to documents with a SideNav) have been accidentally broken in recent commits (e.g. when upgraded to latest material, or enabled animations for DocViewer transitions, etc.). This commit restores the previous behavior by ensuring that (on the initial rendering) the SideNav state is updated as soon as possible and that there will be no animations when: 1. The hamburger button appears. 2. The SideNav is opened. 3. The main section's width is adjusted to make room for the SideNav. PR Close angular#21695
During the initial load of the page (probably until the icon styles are loaded and/or applied), the `.header-link` element is wider, pushing the heading text slightly to the right (for a brief moment). This commit prevents this slight shift by explicitly setting the width for the `.header-link` element. PR Close angular#21695
…lar#21695) Implemented @Maxkorz's [suggestion](angular#21515 (comment)). Fixes angular#21515 PR Close angular#21695
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR fixes several issues. See the commits/commit messages for more details.
(Should be easier to review commit-by-commit and ignoring whitespace in some of them.)
In a nutshell:
WRT header-links on narrow screens...
Before:
After: