Skip to content
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

AutoComplete input does not reflect model changes #2882

Closed
ChrisA9 opened this issue May 25, 2017 · 15 comments
Closed

AutoComplete input does not reflect model changes #2882

ChrisA9 opened this issue May 25, 2017 · 15 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ChrisA9
Copy link

ChrisA9 commented May 25, 2017

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
http://plnkr.co/edit/r7DnQw?p=info

Current behavior
Text does not clear from autocomplete box

Expected behavior
Text should clear from autocomplete box

Please tell us about your environment:
OS : WIndows 7

  • Angular version: 4.0.3

  • PrimeNG version: 4.0.1

  • Browser: Chrome 58.0.3029.110 (64-bit),

@cagataycivici cagataycivici self-assigned this May 26, 2017
@cagataycivici cagataycivici added the Status: Pending Review Issue or pull request is being reviewed by Core Team label May 26, 2017
@cagataycivici cagataycivici added this to the 4.0.2 milestone May 26, 2017
@cagataycivici cagataycivici reopened this May 26, 2017
@sudheerj
Copy link
Contributor

#2778

@cagataycivici cagataycivici changed the title p-autocomplete Values AutoComplete input does not reflect model changes May 29, 2017
@cagataycivici cagataycivici added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels May 29, 2017
@ohadinho
Copy link
Contributor

ohadinho commented Jun 2, 2017

I've installed 4.0.2 but this bug is still there. I'm changing a variable that has a two way binding to a model but the change doesn't reflect the text box value.

@ohadinho
Copy link
Contributor

ohadinho commented Jun 2, 2017

The issue occurs after selecting a value from the dropdown and trying to change it on OnSelect event handler

@sudheerj
Copy link
Contributor

@ohadinho I can't replicate the issue. The value is reflected after button clear using both single and multiple features.

@ohadinho
Copy link
Contributor

ohadinho commented Jun 10, 2017 via email

@thirumalai-kc
Copy link

thirumalai-kc commented Jul 14, 2017

primeNg version: 4.1.0

<p-autoComplete placeholder="Start typing name to see suggestions" formControlName="customerRequest" [suggestions]="customerResults" (completeMethod)="searchCustomer('customer_name', $event.query)" minLength="3" field="accountName" (onSelect)="setCustomerRequest($event)">

Start type 'abc'
Do not choose a value from the option
Perform clear (Here setting customerRequest to null)

Result: customerRequest (model) set to null but the field is not cleared/reset.

Expected: Field should be reset to null.

If I select some value from the option and clear, field is reset to null. Please address this issue.

@macleanpinto
Copy link

Issue exists in 4.1.2 as well

@iblank
Copy link

iblank commented Aug 16, 2017

primeNg version: 4.1.3

I noticed that p-autoComplete expects the model to be type object in the template. If the value is a string, the resolveFieldData method returns undefined, which sets the input value to an empty string.

Changing this fixes it for me:

[value]=\"value ? (field ? objectUtils.resolveFieldData(value,field)||'': value) : null\"

To:

[value]=\"value ? objectUtils.resolveFieldData(value,field)||value : null\"

Alternatively adding this at the top of the resolveFieldData method works as well (and is probably the safer way to handle it):

if (typeof data === 'string') {
    return data;
}

@metacoding
Copy link

metacoding commented Sep 1, 2017

The problem still exists in version 4.1.3, why did you close the issue?

@billfranklin
Copy link

billfranklin commented Sep 5, 2017

@iblank alternate method works for me....please make this change

@omerbuyuksar
Copy link

When i cleared the suggestions input field. It worked for my case. But issue still exists.

@photostu
Copy link

photostu commented Oct 9, 2017

Still broken, wanting to clear the control when a selection is made... I null out the bound model and the suggestions list onSelect within a setTimeout even... when you click elsewhere on the screen, it does clear out

@billfranklin
Copy link

Status of this fix?

@MatteoMeil
Copy link

Found a possiblle workaround.
Check out this comment

@DipankarDDUT
Copy link

Another approach :

Create a template variable suppose
@ViewChild('station', { static: true }) stationDrpdown: ElementRef;

in autoComplete tag #station
(onSelect)="onStationSelection($event)"

onStationSelection(station){
....

this.stationDrpdown['inputFieldValue']=station.name;
...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests