filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
19.51k stars 2.98k forks source link

Searchable select components lose any order given #2771

Closed webtimal closed 2 years ago

webtimal commented 2 years ago

Package

filament/forms

Package Version

v2.12.31

Laravel Version

v9.17.0

Livewire Version

v2.6

PHP Version

PHP 8.1.5

Bug description

The searchable() method on a Select component seems to break the options' ordering. Probably due to the usage of the ChoicesJS library as they are being rendered in the correct order in the view file initially.

This works as intended:

Components\Select::make('client_id')
   ->options(
      Client::orderBy('full_name', 'desc')->get()
         ->pluck('full_name', 'id')
   )

Bild_2022-06-15_021548407

whereas this doesn't

Components\Select::make('client_id')
   ->options(
      Client::orderBy('full_name', 'desc')->get()
         ->pluck('full_name', 'id')
   )
   ->searchable()

Bild_2022-06-15_020224813

I think it would be useful to have a method for providing a column name to sort by.

Steps to reproduce

No response

Relevant log output

No response

wychoong commented 2 years ago

https://github.com/laravel-filament/filament/issues/683#issuecomment-961801569

ryangjchandler commented 2 years ago

Closing since this is a JavaScript thing, not something we can easily workaround right now. If somebody wants to tackle this, please feel free to open a PR and mention this issue, we can re-open it if need be.