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

Component <flux:option> fails to handle value of 0 #696

Closed
KFoobar opened this issue Nov 18, 2024 · 2 comments
Closed

Component <flux:option> fails to handle value of 0 #696

KFoobar opened this issue Nov 18, 2024 · 2 comments

Comments

@KFoobar
Copy link

KFoobar commented Nov 18, 2024

The component for rendering <option> tags within a <select> field fails to correctly handle when the value is set to 0. The issue occurs because the conditional logic in the Blade template skips over values that are set to 0, treating them as falsy.

The issue is in the following code block from flux-pro/stubs/resources/views/flux/option.blade.php:

<?php else: ?>
    <option
        {{ $attributes }}
        @if ($value) value="{{ $value }}" @endif
        @if ($value) wire:key="{{ $value }}" @endif
    >{{ $slot }}</option>
<?php endif; ?>

Reproduction

<flux:select wire:model="type" label="Type" placeholder="Choose type...">
    <flux:option value="1">Type 1</flux:option>
    <flux:option value="0">Type 0</flux:option>
</flux:select>

Solution

@if (isset($value) || $value === 0) value="{{ $value }}" @endif
@jeffchown
Copy link

jeffchown commented Nov 18, 2024

👍 Adds further context to similar issue #667

@calebporzio
Copy link
Contributor

Thanks for this, there was a loose equality check on the $value prop in the option component instead of checking for a strict null.

Will be fixed in the next release. Thanks.

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

3 participants