From ca7ae603c99ea8cb35c33133839d8c4568a3d183 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Tue, 25 Feb 2025 13:07:58 +0100 Subject: [PATCH] make sure combobox dropdown is removed when input field is removed fixes #10319: when a relation membership role is edited, the change will trigger a redraw of the combobox (via D3 exit/enter). In this case, the `blur` event is never called, because the input element is immediately removed from the DOM. This is solved by cleaning up the dropdown when the combobox is about to be removed from the page. --- CHANGELOG.md | 1 + modules/ui/combobox.js | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7952d8617..be69b8673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ _Breaking developer changes, which may affect downstream projects or sites that * Fix too dim markers of selected/hovered photo of some street level imagery layers ([#10755], thanks [@draunger]) * Fix `+` symbol appearing in changeset comments from external tools ([#10766], thanks [@k-yle]) * Fix `destination_sign` relations from being corrupted when splitting a way ([#10646], thanks [@k-yle]) +* Fix combobox dropdown menu sticking around under certain conditions (e.g. while editing the role of a relation member and deselecting a feature #10319) #### :earth_asia: Localization * Add `housename` to address format in Bolivia ([#10727]) #### :hourglass: Performance diff --git a/modules/ui/combobox.js b/modules/ui/combobox.js index 524d31733..aab796ced 100644 --- a/modules/ui/combobox.js +++ b/modules/ui/combobox.js @@ -154,18 +154,8 @@ export function uiCombobox(context, klass) { .on('scroll.combo-scroll', render, true); } - function hide() { - if (_comboHideTimerID) { - window.clearTimeout(_comboHideTimerID); - _comboHideTimerID = undefined; - } - - container.selectAll('.combobox') - .remove(); - - container - .on('scroll.combo-scroll', null); + _hide(container); } @@ -515,7 +505,22 @@ export function uiCombobox(context, klass) { } +function _hide(container) { + if (_comboHideTimerID) { + window.clearTimeout(_comboHideTimerID); + _comboHideTimerID = undefined; + } + + container.selectAll('.combobox') + .remove(); + + container + .on('scroll.combo-scroll', null); +} + + uiCombobox.off = function(input, context) { + _hide(context.container()); input .on('focus.combo-input', null) .on('blur.combo-input', null)