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 itsminWidth
and keeps the initialminWidth
every time its opened. (somewhat the same issue as #3573)This issue partially happens because the
cdk-connected-overlay
sets 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
_triggerWidth
property inmd-select
is never updated either.Here is a plnkr to demonstrate the issue: http://plnkr.co/edit/ERg71p?p=preview
Steps to reproduce
width
of themd-select
component by entering a diff value in thewidth
input box under it. (bothsingle
andmultiple
md-select
's will change)md-select
, and notice thewidth
of thecdk-overlay-pane
remained the same as when it was initially rendered.Proposed fix in PR
We just need to set the new
_triggerWidth
every time themd-select
is opened (open()
) taking into accountdir
/offsetX
and update theoverlayRef#OverlayState
inConnectedOverlayDirective
when thetemplate
is attached.https://github.com/angular/material2/blob/master/src/lib/core/overlay/overlay-directives.ts#L188-L202