components icon indicating copy to clipboard operation
components copied to clipboard

Add public api to autocomplete to check whether it is open

Open jelbourn opened this issue 9 years ago • 8 comments

There is no public api users can consume that tells them whether an autocomplete is open on MdAutocomplete. We should add one.

jelbourn avatar Jul 19 '17 18:07 jelbourn

Hi @jelbourn, I'd like to work on that feature.

We have some emitters for the select component such as onOpen and onClose. I wonder if that would be the best approach or should we publicly export the property showPanel?

Thanks

leocaseiro avatar Aug 15 '17 06:08 leocaseiro

@leocaseiro I was just imagining an isOpen property on MdAutocomplete

jelbourn avatar Aug 15 '17 16:08 jelbourn

This can already be done with the panelOpen property on MdAutocompleteTrigger. I updated this Plunker to prove myself it works.

@jelbourn, do you want to offer it directly in the MdAutocomplete, or should this be fine?

CrlsMrls avatar Aug 18 '17 11:08 CrlsMrls

@carlos- Can't speak for the original intent, but I think this would be nice

<md-autocomplete #auto="mdAutocomplete">
  <md-option *ngFor="let state of filteredStates | async" [value]="state">
    {{ state }}
  </md-option>
</md-autocomplete>

isOpen: {{auto.isOpen}}

since it would eliminate the need for this:

@ViewChild(MdAutocompleteTrigger) trigger: MdAutocompleteTrigger;

isOpen() {
  return this.trigger.panelOpen
}

willshowell avatar Aug 18 '17 13:08 willshowell

@willshowell, I totally agree. On the other hand, the same could apply to openPanel and closePanel. Right?

CrlsMrls avatar Aug 18 '17 14:08 CrlsMrls

@carlos- Thanks for the tip on using MdAutocompleteTrigger. I am using it successfully for one Autocomplete on the page. How can I use it with multiple Autocompletes on the same page?

kkotak avatar Sep 11 '17 19:09 kkotak

Fixed by #7149

josephperrott avatar Oct 03 '17 00:10 josephperrott

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.