Skip to content

fix(overlay): dimension not updated after init #8765

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

Merged
merged 1 commit into from
Feb 8, 2018

Conversation

emoralesb05
Copy link
Contributor

@emoralesb05 emoralesb05 commented Dec 1, 2017

when changing the width of the mat-select (e.g. using flex box) after its rendered, the template[cdk-connected-overlay] does not update its minWidth and keeps the initial minWidth every time its opened.

This issue happens because the cdk-connected-overlay sets the width, minWidth, etc etc only once and never updates it again.

StackBlitz replication: https://stackblitz.com/edit/angular-material2-issue-jbtqvx

Proposed fix in PR

We just need to update the size of the overlay-directive when _attachOverlay() is called if its already been created.

Replaces #6489

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 1, 2017
@emoralesb05 emoralesb05 changed the title feat(select): update the trigger width and overlay state when select is opened feat(select): update overlay state when select is opened Dec 1, 2017
@emoralesb05
Copy link
Contributor Author

@kara @crisbeto let me know if i need to do anything else

hopefully, this can be merged now since this PR chain has been opened since march hahaha 😄

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

Can you also rename the PR? It's not really a feature on the select, but rather a bugfix on the overlay. It can be something along the lines of fix(overlay): dimension not updated after init.

it('should set the width of the overlay based on the trigger and resize', async(() => {
trigger.style.width = '200px';
fixture.detectChanges();
fixture.whenStable().then(() => {
Copy link
Member

Choose a reason for hiding this comment

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

In general we're moving away from async tests, because they tend to be slower and flakier. Can you try to turn this into a fakeAsync one? All you have to do is replace the fixture.whenStable callbacks with a flush call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, will do that

@crisbeto crisbeto self-assigned this Dec 1, 2017
@emoralesb05 emoralesb05 changed the title feat(select): update overlay state when select is opened fix(overlay): dimension not updated after init Dec 1, 2017
@emoralesb05 emoralesb05 force-pushed the select-width-update branch 3 times, most recently from 5587f44 to 1e73167 Compare December 1, 2017 20:19
@emoralesb05
Copy link
Contributor Author

emoralesb05 commented Dec 1, 2017

@crisbeto Done, renamed the commit and replaced async with fakeAsync 👍

it('should set the width of the overlay based on the trigger and resize', fakeAsync(() => {
trigger.style.width = '200px';
fixture.detectChanges();
fixture.whenStable().then(() => {
Copy link
Member

Choose a reason for hiding this comment

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

You can't use fixture.whenStable inside a fakeAsync test. What ends up happening is that the test will complete before the callback is invoked. What I meant before is taking something like this:

fixture.detectChanges();
fixture.whenStable(() => {
  // do stuff
});

And turning it into this:

fixture.detectChanges();
flush();
// do stuff

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated that already, missed it before haha

Copy link
Member

Choose a reason for hiding this comment

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

It seems like you have one left over.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh snap, my bad... thats what i get for trying to do it fast haha.. fixing it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now its done for sure! 😄

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

@crisbeto crisbeto added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Dec 1, 2017
@mmalerba mmalerba added the target: patch This PR is targeted for the next patch release label Dec 6, 2017
@andrewseguin
Copy link
Contributor

Can you check the errors on this?

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this State. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@googlebot googlebot removed the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 13, 2017
@andrewseguin andrewseguin removed the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Dec 13, 2017
@emoralesb05
Copy link
Contributor Author

emoralesb05 commented Dec 13, 2017

Ok, now everything is rebased. Hoping that helps with the CI tests. Does the cla:yes tag need to be added manually now? or how do i trigger that again? @andrewseguin

@emoralesb05
Copy link
Contributor Author

Hmm.. im still not sure why the other tests are failing.. cant seem to figure out why would my code change affect those tests.. any ideas @andrewseguin @crisbeto ?

@BatStak
Copy link

BatStak commented Jan 8, 2018

Is there any news for this issue?

@jelbourn
Copy link
Member

@emoralesb05 could you rebase this PR?

@emoralesb05
Copy link
Contributor Author

Sure, gonna try doing it today @jelbourn 😄

@crisbeto
Copy link
Member

@emoralesb05 are you going to resubmit the PR? Otherwise I don't mind fixing it and it may be easier for me to get it through.

@emoralesb05 emoralesb05 reopened this Jan 28, 2018
@emoralesb05
Copy link
Contributor Author

Sorry @crisbeto forgot to push after the rebase.

There is a unit test issue i'm seeing with tooltip but it seems unrelated to the commit since it was failing when i ran it in master.

Hopefully, we can merge this PR.. and no hard feelings if its easier to close this one and just fix it yourself @crisbeto haha its been opened for sooooo long that i just want to see that fixed.

@emoralesb05
Copy link
Contributor Author

@crisbeto @jelbourn anything else needed for this?

@crisbeto
Copy link
Member

crisbeto commented Feb 1, 2018

I'm not sure why the Bazel check is failing, but it shouldn't be because of the changes in this PR. Do you have an idea @jelbourn?

@jelbourn
Copy link
Member

jelbourn commented Feb 1, 2018

Looks like a flake

@jelbourn jelbourn removed the cla: no PR author must sign Google's Contributor License Agreement: https://opensource.google.com/docs/cla label Feb 1, 2018
@emoralesb05
Copy link
Contributor Author

Can we merge this then? @crisbeto @jelbourn 😄

@mmalerba
Copy link
Contributor

mmalerba commented Feb 7, 2018

@emoralesb05 there's a process we have to follow. we first run a presubmit against google's codebase and watch for any test failures, once all the tests look good it can be merged

@emoralesb05
Copy link
Contributor Author

So do we need to trigger the tests again @mmalerba ??

@mmalerba
Copy link
Contributor

mmalerba commented Feb 8, 2018

nope, nothing for you to do, I just need to do the presubmit

@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 8, 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 target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants