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

feat: added clearable method to select form field #2581

Open
wants to merge 4 commits into
base: 3.x
Choose a base branch
from

Conversation

zeezo887
Copy link
Collaborator

@zeezo887 zeezo887 commented May 6, 2024

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
Copy link
Contributor

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

@Tofandel
Copy link
Contributor

Tofandel commented May 27, 2024

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
Copy link
Member

ifox commented Jun 4, 2024

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.

@ifox ifox changed the title feat: added method to add an empty option to select form field feat: added clearable method to select form field Jun 4, 2024
@ifox ifox added this to the Twill 3.4 milestone Jun 4, 2024
@ifox ifox added the type: enhancement New feature or request label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't unselect option from Select (form field)
3 participants