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

Button: Tooltip remains displayed after button is disabled #3692

Closed
melloware opened this issue Nov 23, 2022 · 3 comments · Fixed by #3696
Closed

Button: Tooltip remains displayed after button is disabled #3692

melloware opened this issue Nov 23, 2022 · 3 comments · Fixed by #3696
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@melloware
Copy link
Member

melloware commented Nov 23, 2022

Describe the bug

Button with showOnDisabled="false" leaves tooltip permanently displayed when disabling the button.

<Button
            type="button"
            label="Save"
            icon="pi pi-check"
            disabled={disabled}
            tooltip={saveBtnTooltipText}
            tooltipOptions={{ showOnDisabled: false }}
            onClick={() => setDisabled(true)}
          />

Reproducer

https://codesandbox.io/s/goofy-merkle-u5hbhs?file=/src/demo/TooltipDemo.js

PrimeReact version

8.7.2

React version

17.x

Language

ALL

Build / Runtime

Create React App (CRA)

Browser(s)

Chrome

Steps to reproduce the behavior

  1. hover button to display tooltip
  2. press button to disable it and the tooltip remains displayed permanently.

Expected behavior

Tooltip should disappear when disabling the button.

@melloware melloware added Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 23, 2022
melloware added a commit to melloware/primereact that referenced this issue Nov 23, 2022
@melloware melloware self-assigned this Nov 23, 2022
@melloware melloware added this to the 8.7.3 milestone Nov 23, 2022
@mertsincan mertsincan reopened this Nov 24, 2022
@github-actions github-actions bot added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 24, 2022
@mertsincan
Copy link
Member

I need to check for changes in Tooltip.js. It breaks some situations in layouts.

@melloware
Copy link
Member Author

Thanks! By switching from Mount Effect + Update Effect to just a single React.useEffect reduces the amount of registered listeners. Show and Hide events were being registered twice on all components and this is due to the fact the functions being added are anonymous.

See MDN: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener

Note: If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an addEventListener call, the second function will also be added to the list of event listeners for that target.

Indeed, anonymous functions are not identical even if defined using the same unchanging source-code called repeatedly, even if in a loop.

Repeatedly defining the same unnamed function in such cases can be problematic. (See Memory issues, below.)

If you go to the current showcase and Inspect the button with a tooltip registered you will see this...

image

@melloware melloware removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 24, 2022
@melloware
Copy link
Member Author

I reverted the tooltip change and opened a new ticket: #3701

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants