question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Open method not working as expected

See original GitHub issue

Open method not working as expected.

Bug description

I’m trying to implement custom “multiple chips select with autocomplete” feature (example here: https://material.angular.io/components/chips/examples) using your autocomplete llibrary.

After selecting an entry I remove it from the [data] input, hence from autocomplete panel. After deleting chips i push the entry back into the [data], entry correctly appears in the panel. Works great for all the cases except when I select all entries and then deselect them. After pushing entries back to [data] list and trying to select them, autocomplete panel won’t open onFocus. I have to click somewhere else and then click back on the input in order to open it.

I have tried to work around this behaviour by forcing open by using open() method inside onFocus(). I am unable to achieve force open.

Expected result

  1. Panel should open when open() is called.
  2. Panel should open onFocus after it was emptied but then filled with data again.

Actual result

  1. Panel doesn’t open on open()
  2. Panel opens only when we click somewhere else first and then click back on autocomplete.

Steps to reproduce

  1. Select ng-autocomplete.
  2. Try to force panel to open.

Template:

     <ng-autocomplete
        #autocompleteInput
        [data]="items"
        [searchKeyword]="keyword"
        (selected)='selectEvent($event)'
        (inputChanged)='onChangeSearch($event)'
        (inputFocused)='onFocused($event)'
        [itemTemplate]="itemTemplate"
        [notFoundTemplate]="notFoundTemplate">
     </ng-autocomplete>
      
     <div>
          <button (click)="openPanel()">OPEN PANEL</button>
     </div>

Component:

@ViewChild('autocompleteInput') autocompleteInput: any;

openPanel() {
    this.autocompleteInput.open();
}

Context

Replicate angular material behaviour without integrating whole angular material library.

Your Environment

  • Version used: 2.0.5
  • Browser Name and version: Chrome Version 95.0.4638.54 (Official Build) (64-bit)
  • Operating System and version: Windows 10
  • Link to your project:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
marexvcommented, Feb 6, 2022

@gmerabishvili Hi, indirectly, by reloading whole component. As far as I am concerned you can close this. Thank you for your effort 💯

1reaction
arvedhansencommented, Nov 23, 2021

I’ve had the same/a similiar problem. I used a FormControl for the value and when the value was null, the panel did neither open on focus or when calling open() manually. When i set the value to an empty string instead of null, it worked as it should.

Read more comments on GitHub >

github_iconTop Results From Across the Web

jQuery get method not working as expected - Stack Overflow
I have my city.js file in a Scripts folder in the UI tier of my ASP.Net MVC application. Now I want to know...
Read more >
window.open method does not provide the expected result
I am using the following method to download a file: window.open(location.origin + res, '_blank'); Expected Behavior A file download should ...
Read more >
Troubleshooting requests - Postman Learning Center
If your API request isn't behaving as expected, there can be many possible reasons. To find out what the problem is, you can...
Read more >
Function.prototype.call() - JavaScript - MDN Web Docs - Mozilla
The call() method calls the function with a given this value and arguments provided individually.
Read more >
Node.js v19.3.0 Documentation
The wrapper function is expected to be called exactly exact times. If the function has not been called exactly exact times when tracker.verify()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found