-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled #13774
fix(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled #13774
Conversation
…y if the floating label is disabled Fixes the first option not appearing as highlighted if the consumer has set `floatLabel="never"` and `autoActiveFirstOption`. It looks like we were depending on the `transitioned` event from the label to kick off the change detection that shows the highlight. Fixes angular#13734.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -493,6 +493,7 @@ export class MatAutocompleteTrigger implements ControlValueAccessor, OnDestroy { | |||
switchMap(() => { | |||
this._resetActiveItem(); | |||
this.autocomplete._setVisibility(); | |||
this._changeDetectorRef.detectChanges(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that it's already set up this way, but I just noticed that it's weird for this switchMap
to have side effects. No action necessary here, but something to keep in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crisbeto @jelbourn As we only need the detectChanges
when firstStable
fires (optionChanges
does not need it, because it is resulting out of an user action) we could limit it to only the firstStable
event. Maybe like so:
return merge(firstStable, optionChanges)
.pipe(
// create a new stream of panelClosingActions, replacing any previous streams
// that were created, and flatten it so our stream only emits closing events...
switchMap((optionChange) => {
this._resetActiveItem();
this.autocomplete._setVisibility();
if (this.panelOpen) {
this._overlayRef!.updatePosition();
}
// Only detectChanges when firstStable fires
if (!optionChange) {
this._changeDetectorRef.detectChanges();
}
return this.panelClosingActions;
}),
// ...
…correctly if the floating label is disabled" (#14396) * Revert "fix(drag-drop): error on touch end (#14392)" This reverts commit 53cecbb. * Revert "fix(menu): reduce specificity of icon selector (#14389)" This reverts commit 74e945a. * Revert "fix(drag-drop): throw better error when attaching to non-element node (#14221)" This reverts commit 31f0e6d. * Revert "fix(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled (#13774)" This reverts commit c99c512.
@crisbeto this somehow broke some tests in google so I had to revert |
… in trigger" (#14398) * Revert "Revert "fix(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled" (#14396)" This reverts commit aa17fbd. * Revert "fix(drag-drop): error on touch end (#14392)" This reverts commit 53cecbb. * Revert "fix(menu): reduce specificity of icon selector (#14389)" This reverts commit 74e945a. * Revert "fix(drag-drop): throw better error when attaching to non-element node (#14221)" This reverts commit 31f0e6d. * Revert "fix(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled (#13774)" This reverts commit c99c512. * Revert "fix(autocomplete): update template when changing autocomplete in trigger (#13814)" This reverts commit 904a5ea.
…y if the floating label is disabled (#13774) Fixes the first option not appearing as highlighted if the consumer has set `floatLabel="never"` and `autoActiveFirstOption`. It looks like we were depending on the `transitioned` event from the label to kick off the change detection that shows the highlight. Fixes #13734.
…correctly if the floating label is disabled" (#14396) * Revert "fix(drag-drop): error on touch end (#14392)" This reverts commit 53cecbb. * Revert "fix(menu): reduce specificity of icon selector (#14389)" This reverts commit 74e945a. * Revert "fix(drag-drop): throw better error when attaching to non-element node (#14221)" This reverts commit 31f0e6d. * Revert "fix(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled (#13774)" This reverts commit c99c512.
… in trigger" (#14398) * Revert "Revert "fix(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled" (#14396)" This reverts commit aa17fbd. * Revert "fix(drag-drop): error on touch end (#14392)" This reverts commit 53cecbb. * Revert "fix(menu): reduce specificity of icon selector (#14389)" This reverts commit 74e945a. * Revert "fix(drag-drop): throw better error when attaching to non-element node (#14221)" This reverts commit 31f0e6d. * Revert "fix(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled (#13774)" This reverts commit c99c512. * Revert "fix(autocomplete): update template when changing autocomplete in trigger (#13814)" This reverts commit 904a5ea.
…y if the floating label is disabled (angular#13774) Fixes the first option not appearing as highlighted if the consumer has set `floatLabel="never"` and `autoActiveFirstOption`. It looks like we were depending on the `transitioned` event from the label to kick off the change detection that shows the highlight. Fixes angular#13734.
…correctly if the floating label is disabled" (angular#14396) * Revert "fix(drag-drop): error on touch end (angular#14392)" This reverts commit 53cecbb. * Revert "fix(menu): reduce specificity of icon selector (angular#14389)" This reverts commit 74e945a. * Revert "fix(drag-drop): throw better error when attaching to non-element node (angular#14221)" This reverts commit 31f0e6d. * Revert "fix(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled (angular#13774)" This reverts commit c99c512.
… in trigger" (angular#14398) * Revert "Revert "fix(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled" (angular#14396)" This reverts commit aa17fbd. * Revert "fix(drag-drop): error on touch end (angular#14392)" This reverts commit 53cecbb. * Revert "fix(menu): reduce specificity of icon selector (angular#14389)" This reverts commit 74e945a. * Revert "fix(drag-drop): throw better error when attaching to non-element node (angular#14221)" This reverts commit 31f0e6d. * Revert "fix(autocomplete): auto-highlighted first option not display correctly if the floating label is disabled (angular#13774)" This reverts commit c99c512. * Revert "fix(autocomplete): update template when changing autocomplete in trigger (angular#13814)" This reverts commit 904a5ea.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes the first option not appearing as highlighted if the consumer has set
floatLabel="never"
andautoActiveFirstOption
. It looks like we were depending on thetransitioned
event from the label to kick off the change detection that shows the highlight.Fixes #13734.