themesberg / themesberg/flowbite

popover.js - memory leak

Open
#245 1 comment 2 reactions 1 assignee View on GitHub

@zoltanszogyenyi is already working on this.

Since Dec 7, 2022.

enhancement v1.6.3
Dominant language
HTML
Stars
9.4k
Forks
862
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
popover.js - eventListeners added mutiple times

 show() {
   ...
  modifiers: [
                ...options.modifiers,
                { name: 'eventListeners', enabled: true },  // concatenation at each call
            ]

options.modifiers is an array, so the above code keep on adding new object at each call of show().

The same mistake is in hide() function.

You should change it to something like that:

function enableListeners(modifiers: Modifier<any, any>[], value: boolean) {
   const modifier = modifiers.find((x) => x.name === 'eventListeners');
   if (!modifier) return [...modifiers, { name: 'eventListeners', enabled: open }];
   modifier.enabled = value;
   return modifiers;
}

show() {
   ...
   modifiers: enableListeners(options.modifiers)
   ...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.