Skip to content

feat(select): update the trigger width and overlay state when select is opened #6489

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

Closed
wants to merge 578 commits into from

Conversation

emoralesb05
Copy link
Contributor

when changing the width of the md-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 partially happens because the cdk-connected-overlay sets the width, minWidth, etc etc only once and never updates it again.

Here is a plnkr to demonstrate the issue: http://plnkr.co/edit/ERg71p?p=preview

Proposed fix in PR

We just need to set the new _triggerWidth every time the md-select is opened (open()) and update the overlayRef#OverlayState in ConnectedOverlayDirective when the template is attached.

New PR to replace what was stated in #3623

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 15, 2017
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

Thanks for the second PR!

/**
* Always set the trigger width since we need to
* update the panel with its new minWidth when opening it
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: For comments inside methods, we typically use // comment style. Applies throughout PR.

@@ -340,6 +345,8 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges {
this._position.withDirection(this.dir);
this._overlayRef.getState().direction = this.dir;
this._initEscapeListener();
/** Update the overlay size, in case the directive's inputs have changed */
this._configureSize(this._overlayRef.getState());
Copy link
Contributor

Choose a reason for hiding this comment

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

The getState() method isn't really meant to be used to set state. @jelbourn and I discussed and we think there should be a dedicated method in OverlayRef to set the size props in the state. There is already an updateSize method, but it's really an internal implementation. So let's:

  • rename the existing updateSize to _setSizeStyles
  • add a new updateSize method that simply updates the size props in the state

Then you can use the new updateSize to set the props here, instead of getState().

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 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping me when it's ready! :)

@emoralesb05
Copy link
Contributor Author

@kara i updated it based on the comments

I wasnt sure if i needed to create a specific interface for the state sizes, but i opted for reusing the OverlayState interface.. just wondering if its worth abstracting width, height, minWidth and minHeight into its own interface for this..

Let me know if i need to change anything else or if i misunderstood anything. 😄

@emoralesb05
Copy link
Contributor Author

I dont know why the unit test failed for md-menu.. it doesnt fail locally for me..

@kara
Copy link
Contributor

kara commented Aug 17, 2017

@emoralesb05 Don't worry about that test; it's a flake (should be fixed by #6514).

@emoralesb05
Copy link
Contributor Author

emoralesb05 commented Aug 17, 2017

@kara Cool, was all confused about it haha 😄

@emoralesb05
Copy link
Contributor Author

@kara @crisbeto do i need to do any other changes? saw that this was opened that will affect this one too #6658

@kara kara assigned kara and unassigned emoralesb05 Aug 30, 2017
@jelbourn
Copy link
Member

@kara @crisbeto is this change still something we want?

@emoralesb05
Copy link
Contributor Author

@jelbourn @kara @crisbeto let me know if this is still needed so i can rebase it 😄 since i saw that @crisbeto opened a similar PR

devversion and others added 13 commits October 12, 2017 14:39
* No longer creates the coverage reports inside of Browserstack. The reports can be generated inside of Chrome Headless that doesn't run remotely on BrowserStack or Saucelabs.
Fixes a few e2e tests that were failing due to subpixel measurement differences.
Due to angular/dgeni-packages#246 the Material docs package used a workaround for accessor types.

The issue has been fixed with angular/dgeni-packages#247 and the workaround can be removed now.
Adds a generic parameter to the `MatDialogConfig` that indicates the type of its `data`.

BREAKING CHANGE: Material now requires at least TypeScript 2.4.

Fixes angular#4398.
Fixes a few obscure test failures on iOS Safari.
…gular#7807)

* Currently the select sets the `multiple` and `disableRipple` values on its options manually. In order to avoid "changed after checked" errors we wrap the calls in promises, however this also forces us to have `async` tests which can time out if the browser is out of focus. These changes add a provider that allows for the options to take the value directly from the select.
* Refactors some unit tests that have been timing out in Firefox to run in the `fakeAsync` zone instead of the `async` one.
Adds the `gulp test:static` task that is identical to `gulp test`, however it doesn't launch Chrome automatically, which is convenient for debugging any browser that isn't Chrome. Currently the debugging flow for other browsers is running the Gulp task which launches Chrome, waiting for it to finish running the tests, connect the other browser, wait for the new browser to finish and then start debugging. With the new task you can just run the Gulp task and connect and disconnect only the relevant browsers.
Fixes a typo in the directory name of one of the examples.
No longer hides the focus indicator ripple on click/space. Right now if a keyboard user tabs to the checkbox and presses SPACE to toggle the checkbox, the focus indicator ripple disappears. This makes it hard to see what element is focused or not.

For comparison, native checkboxes also keep the focus effect on keyboard press. Also Polymer follows the same convention with the focus indicator.
@emoralesb05
Copy link
Contributor Author

Sure, let me try doing it today @crisbeto 😄

devversion and others added 12 commits November 29, 2017 11:17
* Adds support for the `opened` input binding.

Closes angular#8094
…ngular#8269)

Fixes updates to a spinner's value not being saved if they happen while the component is indeterminate, causing it to be wrong if it becomes determinate again.
angular#8270)

Fixes the slide label component collapsing down to 16px if it doesn't have a label.

Fixes angular#8264.
…gular#8514)

Fixes blurry ripples in the slide-toggle, radio and checkbox in Microsoft Edge. The ripples have been blurry because the `border-radius` in an absolute position seems to cause render problems for Edge.

Since the ripples are circular by default, the `border-radius` can be removed and the ripple radius just needs to be set to the value that has been set through CSS before this change. This fixes the blurry ripples in MS Edge and might also improve rendering-stability of the ripples.

Fixes angular#8392
* demo(list): Add accessibility demo page for list

* fix test

* set default role for md-list

* fix test

* Add template file for list
…gular#8674)

Gets rid of all the manual stubs of the `OverlayContainer` in the tests and replaces them with getting the container through DI. This removes some boilerplate and should make things less prone to breaking if we make any changes to the container.
* Adds the material-experimental package.
…on (angular#8099)

* Prevents datepickers that are in a fallback position from overlapping their input by adding an offset.
* Fixes some inconsistent brace spacing.
…#7857)

Currently, when the text of an option is truncated, it ends up removing everything except the ellipsis on Firefox, IE and Edge. These changes fix the truncation and simplify the option view.

Relates to angular#7211.
@emoralesb05
Copy link
Contributor Author

emoralesb05 commented Dec 1, 2017

Im going to close this PR and opened a new one.. i think i screwed up the rebase somehow haha.. im not really good at it lol

Also, turns out the changes needed are minimal.. so i rather do a diff PR and start over again

@emoralesb05 emoralesb05 closed this Dec 1, 2017
@emoralesb05 emoralesb05 deleted the select-update-width branch December 1, 2017 19:55
@emoralesb05
Copy link
Contributor Author

@crisbeto @kara i opened #8765 and added a stackblitz with the bug replication 😄

@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
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.