Junk input elements get created and never destroyed - bad garbage collection
See original GitHub issueI apologize if this has been reported or addressed, but I couldn’t find a similar issue. I ran into an issue I initially thought was my fault in my React app not doing proper garbage collection, but then I reproduced it on your doc site materializecss.com.
I order to understand this, I think a pic is best, but basically hitting the Enter key on an input field produces an additional, hidden input (display: none
) element, 3 at a time, each time you hit Enter and never gets destroyed.
<input type="text" data-dashlane_trigger_mutation="true" style="display: none;">
Expected Behavior
I would expect that these elements are destroyed on the next press of Enter if they are in fact needed at all.
Current Behavior
Pressing Enter produces 3 of these elements each time, seemingly indefinitely.
Changing them from display: hidden
to display: block
produces a single input bottom line (the colored border).
If this is intended behavior, I would suggest using a method that is not so wasteful; these could easily become a memory leak in an SPA.
Possible Solution
Maybe tie an event that checks for the existence of the elements and then uses remove()
to destroy them.
Something like:
function junk() {
const garbage = document.querySelectorAll('[data-dashlane_trigger_mutation="true"]');
if (garbage !== null) garbage.forEach((junk) => junk.remove())
}
Steps to Reproduce (for bugs)
- Go here: https://materializecss.com/text-inputs.html.
- Open the Chrome dev tools using Cmd + Option + I, right-click and Inspect or F12.
- Select Elements and scroll to the bottom (in dev tools, not on the page).
- Place your cursor in the “First Name” field in the first example.
- Press Enter and watch the junk fields get created at the bottom.
Context
The primary issue is the potential for other bugs, unintended behavior and resource usage. I will work around this by implementing something similar to my suggestion in my own app.
Your Environment
- Version used: 1.0.0
- Browser Name and version: Chrome Version 74.0.3729.169 (Official Build) (64-bit) (macOS)
- Operating System and version (desktop or mobile): macOS 10.14.5
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Hey guys, I’m representing Dashlane, that’s our bad sorry for the inconvenience we’ll make sure a fix is shipped with our next extension (soonish).
Thank you for the thorough user support ticket !
Regarding the bug with the extension, can you report it to the support of Dashlane?
Please let us keep updated regarding this if this is just a problem with their approach or if it is a general issue which affects more implementations and use cases so we can take a closer look and provide a solution for all use cases.