From 415c30e60b1a1fad4738331ac1acfb4dc809c374 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Sat, 11 Jan 2025 13:47:36 +0100 Subject: [PATCH] fix search results from being stuck in highlighted state fixes #10661, replaces and closes #10666 See https://github.com/openstreetmap/iD/pull/10666#issuecomment-2585256927 for more details about this fix --- CHANGELOG.md | 1 + modules/ui/feature_list.js | 19 +++++++------------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1344b2ef8..1893db4cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ _Breaking developer changes, which may affect downstream projects or sites that * Render highway direction cones only on matching parent ways ([#9013]) * Prevent edit menu from being covered up by street level imagery or other map overlay panels ([#10495]) * Fix grid lines from showing up on background map tiles in certain situations (semi-transparent tiles or fractional browser zoom level) ([#10594], thanks [@Nekzuris]) +* Prevent search results from sometimes getting stuck in the highlighted state when mouse-hovering the list of search results while typing ([#10661]) #### :earth_asia: Localization * Update Sinitic languages in the Multilingual Names field ([#10488], thanks [@winstonsung]) * Update the list of languages in the Wikipedia field ([#10489]) diff --git a/modules/ui/feature_list.js b/modules/ui/feature_list.js index c7cd95523..f1f7f8c8b 100644 --- a/modules/ui/feature_list.js +++ b/modules/ui/feature_list.js @@ -285,18 +285,15 @@ export function uiFeatureList(context) { list.selectAll('.geocode-item') .style('display', (value && _geocodeResults === undefined) ? 'block' : 'none'); - list.selectAll('.feature-list-item') - .data([-1]) - .remove(); - var items = list.selectAll('.feature-list-item') .data(results, function(d) { return d.id; }); var enter = items.enter() .insert('button', '.geocode-item') .attr('class', 'feature-list-item') - .on('mouseover', mouseover) - .on('mouseout', mouseout) + .on('pointerenter', mouseover) + .on('pointerleave', mouseout) + .on('blur', mouseout) .on('click', click); var label = enter @@ -326,23 +323,21 @@ export function uiFeatureList(context) { .transition() .style('opacity', 1); - items.order(); - items.exit() + .each(d => mouseout(undefined, d)) .remove(); + + items.merge(enter) + .order(); } function mouseover(d3_event, d) { - if (d.id === -1) return; - utilHighlightEntities([d.id], true, context); } function mouseout(d3_event, d) { - if (d.id === -1) return; - utilHighlightEntities([d.id], false, context); }