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

Incorrect Value in URI When Resetting Option in Select #907

Open
3 tasks done
gustavosobrinho01 opened this issue Dec 20, 2024 · 7 comments
Open
3 tasks done

Incorrect Value in URI When Resetting Option in Select #907

gustavosobrinho01 opened this issue Dec 20, 2024 · 7 comments
Assignees

Comments

@gustavosobrinho01
Copy link

Flux version

v1.0.29

Livewire version

v3.5.16

What is the problem?

When using the select as shown in the code and images below, the screen loads with the value 0. When I select the “Ativos” option, the attribute value changes to 1. However, when switching back to the “All Status” option, the value should reset to 0, but as shown in the image, it displays as “Todos+os+Status”.

Image Image

Code snippets

<div>
    <flux:select wire:model="{{ $attributes->wire('model')->value }}"
                 wire:change="{{ $attributes->wire('change')->value }}">
        <flux:option value="0">Todos os Status</flux:option>
        <flux:option value="1">Ativos</flux:option>
        <flux:option value="2">Excluídos</flux:option>
    </flux:select>
</div>
<x-filters.status wire:model="statusSearch" wire:change="filter" autofocus/>

How do you expect it to work?

I expect the value in the URI to be set to 0, not “Todos+os+Status”.

Please confirm (incomplete submissions will not be addressed)

  • I have provided easy and step-by-step instructions to reproduce the bug.
  • I have provided code samples as text and NOT images.
  • I understand my bug report will be closed if I haven't met the criteria above.
@gustavosobrinho01 gustavosobrinho01 changed the title Problem with select options Incorrect Value in URI When Resetting Option in Select Dec 20, 2024
@joshhanley
Copy link
Member

@gustavosobrinho01 thanks for reporting! Can you try using a value other than 0 and see if that works? I suspect there as an issue with how the select is handling a zero value

@gustavosobrinho01
Copy link
Author

With another value, it works, but it should also work with 0, as another value does not meet my needs.

@joshhanley
Copy link
Member

@gustavosobrinho01 yeah agreed, I just wanted to make sure it wasn’t an issue with the first item in the select vs a problem with a 0 value

@thobiasvicente
Copy link

I'm experiencing the same issue.

This behavior is impacting the filter functionality since the expected numeric value isn't being properly set in the URL parameters.

Environment where I reproduced:

  • Flux: v1.1.2
  • Livewire: v3.5.18

@jeffchown
Copy link

jeffchown commented Jan 3, 2025

@gustavosobrinho01 What @joshhanley suspects is probably the case, but I'm curious... If you change your components/filters/status.blade.php to:

<div>
    <flux:select {{ $attributes }}>
        <flux:option value="0">Todos os Status</flux:option>
        <flux:option value="1">Ativos</flux:option>
        <flux:option value="2">Excluídos</flux:option>
    </flux:select>
</div>

and your view code to:

<x-filters.status wire:model.number="statusSearch" wire:change="filter" autofocus/>

does it make any difference?

@gustavosobrinho01
Copy link
Author

gustavosobrinho01 commented Jan 3, 2025

@jeffchown the same problem happens.

@jeffchown
Copy link

Thanks for trying, @gustavosobrinho01

I thought the wire:model.number might cast the value and work. Took a shot.

Looks like it's in @joshhanley 's hands.

@joshhanley joshhanley self-assigned this Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants