wireui / wireui

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

Select Component options detected as null #273

Closed allanpusta13 closed 1 year ago

allanpusta13 commented 2 years ago

Options has value like previously on other versions was working.

Upon update options on dropdown is not rendering and errors occur like it said. "Uncaught TypeError: Cannot convert undefined or null to object"

Laravel 9 Latest WireUi

PH7-Jack commented 2 years ago

Are you using the latest alpinejs version?

allanpusta13 commented 2 years ago

yes

PH7-Jack commented 2 years ago

Could you show me your select config? i.g <x-select .... />

allanpusta13 commented 2 years ago

image image

allanpusta13 commented 2 years ago

image

PH7-Jack commented 2 years ago

@allanpusta13 if you use the WireUI example, does it's work?

<x-select
    label="Select Status"
    placeholder="Select one status"
    :options="[
        ['name' => 'Active',  'id' => 1],
        ['name' => 'Pending', 'id' => 2],
        ['name' => 'Stuck',   'id' => 3],
        ['name' => 'Done',    'id' => 4],
    ]"
    option-label="name"
    option-value="id"
    wire:model.defer="model"
/>
allanpusta13 commented 2 years ago

Also tried it sir but it won't work

PH7-Jack commented 2 years ago

Could you set the default model value to null?

allanpusta13 commented 2 years ago

I'll try

allanpusta13 commented 2 years ago

it has the same error

PH7-Jack commented 2 years ago

Or try to delay the alpine starts, use the WireUI load hook to start the alpinejs, I think is something with the alpine js But, make sure if your wireui, alpine and livewire are updated, and the scripts are in the correct order in your layout https://livewire-wireui.com/docs/get-started

import Alpine from 'alpinejs'

window.Alpine = Alpine

window.Wireui.hook('load', () => Alpine.start())
allanpusta13 commented 2 years ago

I tried it Sir but more errors came up

Tiagospem commented 1 year ago

@PH7-Jack same problem

PH7-Jack commented 1 year ago

Could you reproduce this error in a new project and put it on GitHub? Without the full context is hard to know what is firing this error

allanpusta13 commented 1 year ago

@PH7-Jack Sir I have the sample here, cheers to your work and I love wireui, it would really help me a lot if this would be solved.

All in the composer packages are on their latest versions.

https://github.com/allanpusta13/wireui-select-component-bug

PH7-Jack commented 1 year ago

@allanpusta13 Good, looking at it now.

allanpusta13 commented 1 year ago

Noted and looking forward to your feedback!

PH7-Jack commented 1 year ago

@allanpusta13 The bug only happens when the powergrid scripts is added to the layout

allanpusta13 commented 1 year ago

@PH7-Jack so I have to remove the powergrid script on every form?

PH7-Jack commented 1 year ago

I understand this problem now. Your project was not configured properly with the PowerGrid See this guide Just configure correctly your project. WireUI + PG is a good choice https://livewire-powergrid.com/#/get-started/configure?id=_22-as-a-module

image image

PH7-Jack commented 1 year ago

Remember to use the lastest Alpinejs version

PH7-Jack commented 1 year ago

image

PH7-Jack commented 1 year ago

Closing this issue now.

@allanpusta13 @Tiagospem Only for reference: This error happens because the alpine js is loaded in the script and in the PG CDN. Use only one of these. Import the pg scripts in the app.js module Is better to set the alpine_cdn to null

If this error still happening, tag me with the "RE-OPEN" comment.

allanpusta13 commented 1 year ago

@PH7-Jack worked like a charm! Thanks so much for the tips and solution!

I didn't seem to try to config the powergrid previously because it was working well with the previous versions of wireui.

Again Thanks a lot!!!