From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 207521FF0B4 for ; Fri, 27 Nov 2026 17:13:24 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 5691921748; Fri, 27 Nov 2026 17:13:04 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Subject: [PATCH yew-widget-toolkit 13/38] widget: charts: map: close the info card with the first click after a drag Date: Fri, 27 Nov 2026 17:12:10 +0100 Message-ID: <20261127161241.3713494-14-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261127161241.3713494-1-d.csapak@proxmox.com> References: <20261127161241.3713494-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.254 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: NCQ7YKYQPGP7W2QTDX5RTOPBPROPAS6K X-Message-ID-Hash: NCQ7YKYQPGP7W2QTDX5RTOPBPROPAS6K X-MailFrom: d.csapak@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: A drag sets a flag, so that the click that ends it does not close an open info card. But at least Chromium dispatches that click to the element of the gesture detector instead of the svg element inside of it, which is the one that listens for it. So the flag stayed set and swallowed the next real click on the map instead. To fix that, listen for the click on the container around the gesture detector. A touch pan does not end with a click at all, so also reset the flag when a pointer goes down. That always happens before a click that is meant as one, and never between a drag and the click that ends it. Signed-off-by: Dominik Csapak --- src/widget/charts/map/mod.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/widget/charts/map/mod.rs b/src/widget/charts/map/mod.rs index abc6470..bb1fad8 100644 --- a/src/widget/charts/map/mod.rs +++ b/src/widget/charts/map/mod.rs @@ -97,6 +97,7 @@ pub enum Msg { CloseInfo, Drag(GestureDragEvent), UpdateInfoAlignment, + PointerDown, } #[derive(PartialEq, Clone)] @@ -412,6 +413,11 @@ impl yew::Component for MapComp { } } } + Msg::PointerDown => { + // not every drag ends with a click to consume, a touch pan does not + self.dragged = false; + return false; + } Msg::CloseInfo => { // a pan emits a trailing click; consume it here instead of dismissing the card if self.dragged { @@ -444,12 +450,6 @@ impl yew::Component for MapComp { let fully_zoomed = zoom_level >= props.max_zoom_level; let svg = Canvas::new() - .onclick({ - // clicking the map background (anything but a point, which stops propagation) - // dismisses an open info card - let link = link.clone(); - move |_| link.send_message(Msg::CloseInfo) - }) .onwheel({ let link = link.clone(); move |event: WheelEvent| { @@ -557,6 +557,11 @@ impl yew::Component for MapComp { .class(css::JustifyContent::Center) .width("100%") .height("100%") + // Clicking the map background (anything but a point, which stops + // propagation) dismisses an open info card. The click that ends a drag goes + // to the gesture detector instead of the map, so listen around both. + .onclick(link.callback(|_| Msg::CloseInfo)) + .onpointerdown(link.callback(|_| Msg::PointerDown)) .with_child( GestureDetector::new( svg.with_child(points) -- 2.47.3