mirror of
https://github.com/marcominerva/SqlDatabaseVectorSearch.git
synced 2026-06-20 12:23:10 +00:00
Add tooltip feedback for clipboard copy action
Introduce a tooltip feature in `Ask.razor` that provides user feedback when copying text to the clipboard. Added `isCopied` to track the copy state and `toolTipText` to manage the tooltip message. The tooltip title updates from "Copy to Clipboard" to "Copied!" after the action, with a delay to reset the message for subsequent copies.
This commit is contained in:
@@ -58,7 +58,7 @@
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-end bg-transparent">
|
<div class="text-end bg-transparent">
|
||||||
<Tooltip Title="Copy to Clipboard" Color="TooltipColor.Dark" Placement="TooltipPlacement.Bottom">
|
<Tooltip Title="@toolTipText" Color="TooltipColor.Dark" Placement="TooltipPlacement.Bottom">
|
||||||
<Button Type="ButtonType.Button" Outline="false" @onclick="@(async () => await CopyToClipboardAsync(message.Text))">
|
<Button Type="ButtonType.Button" Outline="false" @onclick="@(async () => await CopyToClipboardAsync(message.Text))">
|
||||||
@if (isCopied)
|
@if (isCopied)
|
||||||
{
|
{
|
||||||
@@ -116,7 +116,9 @@
|
|||||||
|
|
||||||
private Guid conversationId = Guid.NewGuid();
|
private Guid conversationId = Guid.NewGuid();
|
||||||
private bool isAsking = false;
|
private bool isAsking = false;
|
||||||
|
|
||||||
private bool isCopied = false;
|
private bool isCopied = false;
|
||||||
|
private string toolTipText = "Copy to Clipboard";
|
||||||
|
|
||||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||||
{
|
{
|
||||||
@@ -218,10 +220,12 @@
|
|||||||
await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", text);
|
await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", text);
|
||||||
|
|
||||||
isCopied = true;
|
isCopied = true;
|
||||||
|
toolTipText = "Copied!";
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
await Task.Delay(1500); // Mostra il segno di spunta per 1.5 secondi
|
await Task.Delay(1500); // Shows the checkmark for 1.5 seconds
|
||||||
|
|
||||||
|
toolTipText = "Copy to Clipboard";
|
||||||
isCopied = false;
|
isCopied = false;
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user