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

fix(navbar): update ink bar when links change #4897

Merged
merged 5 commits into from
Jun 5, 2017

Conversation

andrewseguin
Copy link
Contributor

@andrewseguin andrewseguin commented May 31, 2017

Fixes #4737, #4738

When the list of tab links change, the ink bar should adjust to make sure it's positioned under the right element. E.g. tabs are added/removed/moved/content changed

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label May 31, 2017
@@ -37,10 +41,14 @@ export class MdTabNavBar implements AfterContentInit, OnDestroy {
/** Combines listeners that will re-align the ink bar whenever they're invoked. */
private _realignInkBar: Subscription = null;

/** Subject that emits when the component has been destroyed. */
private _onDestroy = new Subject<void>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having an internal Subject, why not save the subscription and unsubscribe on destroy instead? On a related note, I wonder whether the _tabLinks wouldn't get completed automatically on destroy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both work, playing with the idea of using this subject for our components' subscriptions. It's an idea Rob is considering making "a thing" that seems to play nice with observables and lets you avoid storing the subscription in another variable.

What do you think about this @jelbourn

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels May 31, 2017
@andrewseguin andrewseguin removed pr: lgtm action: merge The PR is ready for merge by the caretaker labels May 31, 2017
@andrewseguin
Copy link
Contributor Author

Changed the strategy to tackle another issue - align ink bar when the inner HTML changes. Using mutation observers to know when the content is changed. Can use this for when links are added/removed/moved as well as when their content has changed (and perhaps their width).

@jelbourn can you re-review?

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor comment

(add merge-ready when done)

expect(inkBar.alignToElement).toHaveBeenCalled();
});

it('should re-align the ink bar when the tab labels change the width', done => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this test use the done callback instead of fakeAsync? I actually don't see why either is necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing seemed to be able to trigger the mutation observer (detect changes, flush microtasks, etc). Took a cue from observe-content.spec.ts which uses done => () as well.

@andrewseguin andrewseguin added the action: merge The PR is ready for merge by the caretaker label Jun 5, 2017
@andrewseguin andrewseguin merged commit 41c43cc into angular:master Jun 5, 2017
@andrewseguin andrewseguin deleted the 4737-nav-tabs branch November 28, 2017 20:35
@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 Sep 7, 2019
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 cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Navtabs active index wrong
6 participants