-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Datepicker creating detached elements #3846
Comments
@joel-szakall Thank you for letting me know about this issue. If you could please send me a code pen that would be great. I'll get to work on this when I have some free time. Thanks |
@joel-szakall @wesdevpro I have investigated the problem on Edge on macOS. And I have found
|
@joel-szakall @wesdevpro Here is what happens under the hood:
buefy/src/directives/trapFocus.js Line 21 in d3bd40d
This step stores a new "keydown" event handler in buefy/src/directives/trapFocus.js Lines 29 to 45 in d3bd40d
This step removes buefy/src/directives/trapFocus.js Lines 50 to 52 in d3bd40d
This is why you see the
This overwrites
|
Having two or more |
@kikuomax It looks like I have some more learning to do 🤣 |
Overview of the problem
Buefy version: 0.9.23 (I think it was also happening in 0.9.14 as well)
Vuejs version: 2.6.14
OS/Browser: Edge 111.0.1661.44 (64-bit) on Windows 10; Chrome
Description
Event listeners are not being unbound on Datepicker child components after it is destroyed, causing a memory leak due to detached elements that are not cleaned up by the garbage collector.
Steps to reproduce
Expected behavior
All event listeners and DOM elements cleaned up/destroyed and garbage collected after Datepicker component is destroyed.
Actual behavior
After being destroyed, the Datepicker component is removed from the DOM, but its elements are still being referenced in code, thus retaining the detached elements in memory. I suspect the culprit to be located in the bind() and unbind() functions in the 'trapFocus.js' directive. It appears unbind() is not being run for 'onKeyUp' event listeners for some/all elements within the child components of the Datepicker, and these events are holding onto references for the days of the month and other keyboard-navigable elements (I saw some on anchor elements). I think the elements with 'onKeyUp' are being deleted from the DOM before unbind() can be performed on them. Every parent component (if the Datepicker is nested inside other components) is also being held onto in memory due to this issue.
At times, these detached elements persist through page reloads as well; closing and reopening the app in a new window/tab, or navigating to a different address and then navigating back to the app clears the detached elements.
The text was updated successfully, but these errors were encountered: