From 5f2d7b5b31283fd6d85e8b2a355119a3194399b9 Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Thu, 15 Jan 2026 22:47:55 -0500 Subject: [PATCH] Enhance InteractiveChip component with touch support and control visibility This commit updates the InteractiveChip component to improve user interaction on touch devices. It introduces touch event handling to toggle control visibility, ensuring that controls are always displayed on mobile devices while allowing hover-based visibility on desktop. The AlwaysShowControls parameter has been added to manage control display behavior, enhancing the overall usability of the component. These changes contribute to a more responsive and accessible user interface. --- .../Shared/Components/InteractiveChip.razor | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/WebApp/Components/Shared/Components/InteractiveChip.razor b/WebApp/Components/Shared/Components/InteractiveChip.razor index 3855a6f..35a2523 100644 --- a/WebApp/Components/Shared/Components/InteractiveChip.razor +++ b/WebApp/Components/Shared/Components/InteractiveChip.razor @@ -1,10 +1,14 @@ @namespace WebApp.Components.Shared.Components +@using Microsoft.AspNetCore.Components.Web + @onmouseleave="@(() => _isHovered = false)" + @ontouchstart="@(() => _isTouched = true)" + @ontouchend="@(() => { /* Prevent mouse events on touch */ })" + @onclick="@HandleClick"> @ChildContent - @if (_isHovered && ControlContent != null) + @if (ControlContent != null) { - @ControlContent - } + @* Always show controls on mobile/touch devices *@ + + @ControlContent + + @* Show on hover for desktop devices *@ + + @if (_isHovered || AlwaysShowControls || _isTouched) + { + @ControlContent + } + + } @@ -46,5 +60,18 @@ [Parameter] public string? WrapperClass { get; set; } + [Parameter] + public bool AlwaysShowControls { get; set; } = false; + private bool _isHovered = false; + private bool _isTouched = false; + + private void HandleClick(MouseEventArgs e) + { + // On touch devices, toggle controls on tap (for devices with both touch and mouse) + if (_isTouched) + { + _isTouched = !_isTouched; + } + } } \ No newline at end of file