TW-Elements icon indicating copy to clipboard operation
TW-Elements copied to clipboard

[Select] setValue didn't do anything after filter

Open AndoruKun opened this issue 2 years ago • 4 comments

Describe the bug Hy, i got some bug on select input. im using attribute filter on my select component then i have some button to reset the value for form. i do filter in my select component data because its to many data from my api so after i filter and select i hit api after that i click button reset in that function has setValue from instance my component select that didn't change any thing or

i have create in playground so you guys can try https://tw-elements.com/snippets/tailwind/andrew_lim/5862792

To Reproduce Steps to reproduce the behavior:

  1. open select component
  2. filter data from field search
  3. select data filter
  4. click button where inside of function there have selectInstance to set value '' or null or any thing
  5. then value doesn't change what we want

Expected behavior value has change after we set value from method

Actual behavior didn't change the value

Show your code playground url https://tw-elements.com/snippets/tailwind/andrew_lim/5862792

AndoruKun avatar Dec 22 '23 09:12 AndoruKun

Hello! Thanks for letting us know about this issue! I'm adding this issue to our project.

BTW If you are making calls to the API, maybe the autocomplete component would fit your needs there? We have an example with asynchronous search that can be found here:

https://tw-elements.com/docs/standard/forms/autocomplete/#asynchronous-search

Best Regards!

juujisai avatar Dec 26 '23 17:12 juujisai

I was going to open this exact same issue, but for Angular.

Pretty much the same behavior, but also happens with NgModel (or pretty much any data binding)

Filtering and selecting after typing something sets the date for my model, but after that, it's stuck forever

I'll try the autocomplete suggestion tho, might be a good workaround

<select data-te-select-init
        data-te-select-size="lg"
        data-te-select-filter="true"
        data-te-select-no-result-text="Não encontrado"
        data-te-select-search-placeholder="buscar..."
        data-te-select-clear-button="true"
        [(ngModel)]="selectedUF"
        (ngModelChange)="onSelectedUFChange($event)"
        [disabled]="ufs.length < 2  || disabled"
        id="selectUnidadeFederativa">
    <option value=""></option>
    <option *ngFor="let item of ufs; index as i;" value="{{item.UF}}">{{item.UF}}</option>
</select>
<label data-te-select-label-ref class="z-10" [ngClass]="{'required' : isRequired === true}">UF</label>

andremartinez avatar Jan 16 '24 22:01 andremartinez

I was going to open this exact same issue, but for Angular.

Pretty much the same behavior, but also happens with NgModel (or pretty much any data binding)

Filtering and selecting after typing something sets the date for my model, but after that, it's stuck forever

I'll try the autocomplete suggestion tho, might be a good workaround

<select data-te-select-init
        data-te-select-size="lg"
        data-te-select-filter="true"
        data-te-select-no-result-text="Não encontrado"
        data-te-select-search-placeholder="buscar..."
        data-te-select-clear-button="true"
        [(ngModel)]="selectedUF"
        (ngModelChange)="onSelectedUFChange($event)"
        [disabled]="ufs.length < 2  || disabled"
        id="selectUnidadeFederativa">
    <option value=""></option>
    <option *ngFor="let item of ufs; index as i;" value="{{item.UF}}">{{item.UF}}</option>
</select>
<label data-te-select-label-ref class="z-10" [ngClass]="{'required' : isRequired === true}">UF</label>

yeah that true after you doing filter and select the value it will be stuck forever because this TW-element core basic on native they don't detect to framework just like angular or nuxt and anything so my options better use value then maybe it will work. so if you got like me after setValue best temp resolve its just dispose and init again it will be fixing @andremartinez

AndoruKun avatar Jan 17 '24 02:01 AndoruKun

yeah that true after you doing filter and select the value it will be stuck forever because this TW-element core basic on native they don't detect to framework just like angular or nuxt and anything so my options better use value then maybe it will work. so if you got like me after setValue best temp resolve its just dispose and init again it will be fixing

Thanks for the suggestion @AndoruKun , because of some deadlines I had to simply remove tw-elements from the selects and implement other solutions.

I'll probably test this again once v2.0,0 is out.

andremartinez avatar Jan 18 '24 15:01 andremartinez