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

Respond immediately to tap on option in inputOptions #2725

Closed
peterlondon1 opened this issue Apr 25, 2024 · 2 comments
Closed

Respond immediately to tap on option in inputOptions #2725

peterlondon1 opened this issue Apr 25, 2024 · 2 comments

Comments

@peterlondon1
Copy link

peterlondon1 commented Apr 25, 2024

New feature motivation

Cut out one tap/click

New feature description

Is there any way to respond to the tap/click on one of the choices in an inputOptions pulldown list directly, rather than when the OK (or cancel) buttons are tapped?

@peterlondon1 peterlondon1 changed the title Response immediately to tap on option in inputOptions Respond immediately to tap on option in inputOptions Apr 25, 2024
@limonte
Copy link
Member

limonte commented Apr 25, 2024

That'd be a bad UX, but here you go in case you want to annoy your users 😄

Swal.fire({
  input: 'select',
  inputOptions: {
    apples: 'Apples',
    bananas: 'Bananas',
  },
  didOpen: () => {
    const select = Swal.getInput()
    select.addEventListener('change', () => {
      Swal.clickConfirm()
    })
  },
})

@limonte limonte closed this as completed Apr 25, 2024
@peterlondon1
Copy link
Author

peterlondon1 commented Apr 25, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants