nextui icon indicating copy to clipboard operation
nextui copied to clipboard

[BUG] - DropdownItem onPress not working

Open dl-web-dev opened this issue 2 years ago • 6 comments

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

dl-web-dev avatar Apr 16 '24 18:04 dl-web-dev

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

dg-essertech avatar Apr 16 '24 19:04 dg-essertech

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 avatar Apr 16 '24 21:04 jrgarciadev

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

jrgarciadev avatar Apr 16 '24 21:04 jrgarciadev

@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.

Reynard-G avatar Apr 17 '24 04:04 Reynard-G

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

jmndao avatar Apr 17 '24 11:04 jmndao