primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Floating-label on p-autocomplete unfloating after selection

Open VNYoeri opened this issue 9 years ago • 4 comments

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

[ x ] bug report
[ ] feature request
[ ] support request

Plunkr Case (Bug Reports) PrimeNG 4.2.0: http://plnkr.co/edit/nSHT6iIkXi5IgRKkRJC3?p=preview

Edit, PrimeNG 4.3.0: http://plnkr.co/edit/bYQgsuYbgxhL9Y3ceybD?p=preview

Current behavior As described in issue #4145 (and globally in #4011), the floating-labels are not floating after selecting an item in the dropdownlist, when the dropdown is triggered by the MouseEvent. When selecting an item by triggering an InputEvent, the label keeps floating as it should even when the next event is a MouseEvent. When clearing the selected item using backspace and change the focus to another element, this can be reproduced. So, in short: if the MouseEventis triggered without an earlier InputEvent (unless the input has been cleared using backspace), the label isn't floating.

Expected behavior The label keeps floating, no matter the eventType.

Minimal reproduction of the problem with instructions In the Plunkr, you can see there's a <p-autocomplete> with a `(completeMethod)="search($event)"'.

  1. Trigger the completeMethod in the autocomplete-UI by CLICKING the dropdown-button
  2. Select an item in the list
  3. Click away from the autocomplete to lose focus.

Please tell us about your environment:

  • OS: Windows 10 64b

  • IDE: IntelliJ Ultimate 2017.2.5

  • Angular version: 4.4.6

  • PrimeNG version: 4.3.0

  • Browser: All

  • Language: TypeScript 2.0.3

Edit: added reference to original, global, issue.

VNYoeri avatar Oct 31 '17 10:10 VNYoeri

Works for me on 4.3.0;

    <span class="ui-float-label">
        <p-autoComplete [(ngModel)]="country" inputId="float-input" [suggestions]="filteredCountriesSingle" (completeMethod)="filterCountrySingle($event)" field="name" [size]="30"
            [minLength]="1"></p-autoComplete>
        <label for="float-input">Username</label>
    </span>

Provide a plunkr on 4.3.0 please;

http://plnkr.co/edit/6q5v84DWolH6DeAdi70w?p=info

cagataycivici avatar Nov 06 '17 11:11 cagataycivici

@cagataycivici, your code is not triggering the bug because the bug-causing attribute is not present...

My previous Plunkr was on 4.3.0 (checked it in "systemjs.config.js": 'primeng': 'npm:[email protected]' to be sure). Anyways, I created a new Plunkr based on the given URL: http://plnkr.co/edit/KHw1AJ5legYuFXAcsR6I?p=preview

<span class="ui-float-label">
  <p-autoComplete id="foo" [suggestions]="resultsFilter" (completeMethod)="search($event)" 
            [dropdown]="true">
    <ng-template let-resultItems>
      <div class="ui-helper-clearfix">
        <div>{{resultItems}}</div>
      </div>
    </ng-template>
  </p-autoComplete>
  <label for="foo">Never keep floating</label>
</span>

It is NOT working.... your example is NOT using the [dropdown]="true"... if you read the case-description thorough, you'll see that I stated:

the floating-labels are not floating after selecting an item in the dropdownlist, when the dropdown is triggered by the MouseEvent

VNYoeri avatar Nov 06 '17 12:11 VNYoeri

@cagataycivici could you please check this out again?

VNYoeri avatar Nov 09 '17 14:11 VNYoeri

@cagataycivici I can conform it's fixed using PrimeNG5!! Thank you very much for this quick fix!

VNYoeri avatar Nov 21 '17 09:11 VNYoeri