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

[BUG] - DropdownItem onPress not working #2743

Closed
dml0031 opened this issue Apr 16, 2024 · 6 comments · Fixed by #2746 or #2767
Closed

[BUG] - DropdownItem onPress not working #2743

dml0031 opened this issue Apr 16, 2024 · 6 comments · Fixed by #2746 or #2767
Labels
🐛 Type: Bug Something isn't working

Comments

@dml0031
Copy link

dml0031 commented Apr 16, 2024

NextUI Version

2.3.0

Describe the bug

After the update, when trying to click on a DropdownItem using the onPress click handler, nothing happens. The dropdown just closes. If I disable closeOnSelect for both the Dropdown and DropdownItem and then try and use the onPress handler it works as intended.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Add items to a Dropdown
  2. Add onPress handler to DropdownItem inside the dropdown
  3. Click on the dropdown Item
  4. Dropdown will close without action inside the onPress does anything

Expected behavior

Expect the onPress action to complete when clicking on the DropdownItem

Screenshots or Videos

No response

Operating System Version

Any

Browser

Chrome

@dml0031 dml0031 added the 🐛 Type: Bug Something isn't working label Apr 16, 2024
Copy link

linear bot commented Apr 16, 2024

@daniel-esserweb
Copy link

I also have this issue, not only in the dropdown some others component also that have onPress action dont work

@jrgarciadev
Copy link
Member

Hey guys, we're currently looking into this issue, please use the onAction in the meantime

e.g.

https://stackblitz.com/edit/vitejs-vite-sell4f?file=src%2FApp.tsx

@jrgarciadev
Copy link
Member

@daniel-esserweb could you please tell us on which other components the onPress is not working?

@Reynard-G
Copy link

@jrgarciadev I've tested with console.log & Server Actions on onPress & onClick, both of which don't seem to work in the current version. Tested v2.2.10 and both event handlers work as expected.

@jmndao
Copy link

jmndao commented Apr 17, 2024

Same issues here, I don't why it stop functioning at some point.

As per @jrgarciadev

Hey guys, we're currently looking into this issue, please use the onAction in the meantime

e.g.

https://stackblitz.com/edit/vitejs-vite-sell4f?file=src%2FApp.tsx

I'm resorted to use switch-case on the key to trigger different actions

const onAction = (key: Key) => {
    switch (key) {
      case "edit":
        // Handle edit action
        break;
      case "view":
        router.push(`/tasks/${task.id}`);
        break;
      case "delete":
        showConfirmModal();
        break;
      default:
        break;
    }
  };

Note: Need to make sure every dropdown-item has a unique key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something isn't working
Projects
None yet
5 participants