mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-25 09:15:49 +03:00
fix : Global click handler is (re)bound once per field – memory-leak & duplicate callback risk
This commit is contained in:
parent
aeeda5755f
commit
94b7d301a0
1 changed files with 7 additions and 4 deletions
|
@ -3625,8 +3625,7 @@ osd.initialize = function (callback) {
|
|||
};
|
||||
// Hide all menus function
|
||||
const hideAllMenus = () => {
|
||||
$(".osd-context-menu").removeClass("show");
|
||||
$(".osd-position-grid").removeClass("show");
|
||||
$(".osd-context-menu, .osd-position-grid").removeClass("show");
|
||||
};
|
||||
// Event handlers
|
||||
let menuTimeout;
|
||||
|
@ -3664,8 +3663,12 @@ osd.initialize = function (callback) {
|
|||
$(this).removeClass("show");
|
||||
});
|
||||
// Global click handler to close menus
|
||||
globalMenuClickHandler = hideAllMenus;
|
||||
$(document).on("click", globalMenuClickHandler);
|
||||
if (!globalMenuClickHandler) {
|
||||
globalMenuClickHandler = () => {
|
||||
hideAllMenus();
|
||||
};
|
||||
$(document).on("click", globalMenuClickHandler);
|
||||
}
|
||||
// Make field container relative positioned to contain the absolute positioned menu
|
||||
$field.css("position", "relative");
|
||||
// Append all elements
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue