Skip to content

[BUG] Click events not working as expected #1141

Closed

Description

@viswajeet1996

Hello,

I am trying to update my react-tooltip version from v4 to v5. I have a list of items and I want to show the tooltip on click of every item.
The issue is when I click on the first item it shows the tooltip, when I click on a second item it closes the first tooltip but does not open the second one, and to open the tooltip for the second item I need to click again on the second tooltip. Below is my code snippet. Please let me know if I am doing something wrong with this implementation

<StyledTopTenItems>      
      <Tooltip
        id="my-tooltip"
        openEvents={{ click: true }}
        closeEvents={{ click: true }}
        variant="light"
        opacity={1}
      />
      {items.map((item, index) => (
        <div key={index} className="top-items">
          <span
            className="item-name"
            data-tooltip-content={item.name}
            data-tooltip-id="my-tooltip"
          >
            {item.name}
          </span>
         <span className="item-allocation">{item.value}</span>
        </div>
      ))}
</StyledTopTenItems>

Activity

  1. changed the title [-]Tooltip with list of items not working[/-] [+][BUG] Click events not working as expected[/+] on Dec 20, 2023
  2. gabrieljablonski commented on Dec 20, 2023

    @gabrieljablonski
    Member

    I'm quite surprised this hasn't come up before, since it's a pretty significant bug.

    Please try react-tooltip@5.25.1-beta.1142.0 and let me know if it works as expected.

  3. viswajeet1996 commented on Dec 20, 2023

    @viswajeet1996
    Author

    Hi @gabrieljablonski,

    Thanks for the quick response. I am not able to use the react-tooltip@5.25.1-beta.1142.0, I am getting the below error. I am able to use react-tooltip@5.25.1-beta.1140.0

    image

  4. gabrieljablonski commented on Dec 20, 2023

    @gabrieljablonski
    Member

    @viswajeet1996 Please try again. As you can see below, this beta version is already available through npmjs.com

    https://www.npmjs.com/package/react-tooltip/v/5.25.1-beta.1142.0

    If it still doesn't work, try waiting a bit longer. It should work eventually.

  5. viswajeet1996 commented on Dec 22, 2023

    @viswajeet1996
    Author

    @gabrieljablonski I have added the beta version provided by you and it has fixed the issue. Thanks for the quick release.

  6. gabrieljablonski commented on Dec 22, 2023

    @gabrieljablonski
    Member

    @viswajeet1996 good to know. You'll get a notification when we close this and release an official version with the fix, but that beta version should work fine until then.

  7. gabrieljablonski commented on Dec 27, 2023

    @gabrieljablonski
    Member

    Official release react-tooltip@5.25.1 fixes this and some other stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions