area17 / twill

Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
https://twillcms.com
Apache License 2.0
3.75k stars 572 forks source link

feat: added clearable method to select form field #2581

Open zeezo887 opened 5 months ago

zeezo887 commented 5 months ago

Description

Allows the user to clear the selected option:

Select::make()
  ->name('field')
  ->options(
      Options::make([
          Option::make('value', 'label'),
          Option::make('value2', 'label2'),
      ])
  )
  ->clearable()

Related Issues

Fixes #2562

Tofandel commented 4 months ago

I think clearable makes more sense, then we could show a clear button on the select input

Tofandel commented 4 months ago

There seems to be already what is needed on the VSelect component to make it work https://github.com/area17/twill/blob/3.x/frontend/js/components/VSelect/ExtendedVSelect.vue#L42-L44C7

But it seems it's not the component that is used https://github.com/area17/twill/blob/3.x/frontend/js/components/SingleSelect.vue

ifox commented 4 months ago

I implemented clearable instead as discussed. By default the Select field does use vue-select. It doesn't only if unpack or native are true.