feat(select): update the trigger width when select is opened #3623
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When changing the width of the
md-select(e.g. using flex box) after its rendered, thetemplate[cdk-connected-overlay]does not update itsminWidthand keeps the initialminWidthevery time its opened. (somewhat the same issue as #3573)This issue partially happens because the
cdk-connected-overlaysets thewidth,minWidth, etc etc only once and never updates it again.https://github.com/angular/material2/blob/master/src/lib/core/overlay/overlay-directives.ts#L181
But also because the
_triggerWidthproperty inmd-selectis never updated either.Here is a plnkr to demonstrate the issue: http://plnkr.co/edit/ERg71p?p=preview
Steps to reproduce
widthof themd-selectcomponent by entering a diff value in thewidthinput box under it. (bothsingleandmultiplemd-select's will change)md-select, and notice thewidthof thecdk-overlay-paneremained the same as when it was initially rendered.Proposed fix in PR
We just need to set the new
_triggerWidthevery time themd-selectis opened (open()) taking into accountdir/offsetXand update theoverlayRef#OverlayStateinConnectedOverlayDirectivewhen thetemplateis attached.https://github.com/angular/material2/blob/master/src/lib/core/overlay/overlay-directives.ts#L188-L202