wireui / wireui

TallStack UI components
https://v1.wireui.dev
MIT License
1.37k stars 166 forks source link

New validateConfig() in native select breaks option-key-value functionality #267

Closed babist closed 1 year ago

babist commented 2 years ago

Describe the bug I cannot use option-key-value anymore in selects.

To Reproduce Steps to reproduce the behavior:

  1. Add <x-select>
  2. Add :option-key-value="true"
  3. Do NOT add option-value
  4. Add option-label
  5. Try to render

To Solve Fix validateConfig() in NativeSelect.php to take option-key-value into account.

PH7-Jack commented 2 years ago

Hello @babist It's the expected behavior. You must use the option label and value together. The option-key-value is only for an array of primitive values, like string, number...

babist commented 1 year ago

I do not understand why option-key-value should only be used with primitive values. Please take a look at my case:

I have this array in my app's config:

[
    // ...

    'statuses' => [
        'confirmed' => [
            'label' => 'Confirmed',
        ],
        'awaiting_payment' => [
            'label' => 'Awaiting Payment',
        ],
        'paid' => [
            'label' => 'Paid',
            'warning' => 'Some warning...',
        ],
        'shipped' => [
            'label' => 'Shipped',
            'warning' => 'Another warning',
        ],
    ],

]

The options' values need to be the keys of the statuses array, but their label should be the label key of each element.

PH7-Jack commented 1 year ago

@babist Interesting...

babist commented 1 year ago

Is this going to be fixed? Should I try to create a PR?

PS. sorry for the late response, I was on holiday.

PH7-Jack commented 1 year ago

@babist it's going to be released today. I was fixing a performance issue before fix it

babist commented 1 year ago

Wow, already?! That's awesome, thanks!

PH7-Jack commented 1 year ago

@babist Thanks for changing my opinion about that. You're right, thanks.

PH7-Jack commented 1 year ago

Update to the latest release to see the changes

babist commented 1 year ago

Yaay! Thanks for the update!