fix(webui): make action feedback easier to notice (#6702)
* fix(webui): make action feedback easier to notice * fix(webui): preserve undo and report confirmed action results * refactor(webui): trim toast preview and redundant coverage * test(webui): advance the undo window for the last topic deletion
This commit is contained in:
1 parent
0f45d74fec
commit
9ccf3b6214
59 files changed
+1621
-508
No files matched your search
@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";
|
||||
|
||||
import { floatingItemClassName, floatingItemFocusClassName, floatingSurfaceClassName, floatingSurfaceMotionClassName } from "@/components/ui/floating-surface";
|
||||
import { useFloatingPortal } from "@/components/ui/floating-portal";
|
||||
import { useToast } from "@/components/ui/toast";
|
||||
import { copyTextToClipboard } from "@/lib/clipboard";
|
||||
import type { FileReferenceMetadata, FilePreviewPayload } from "@/lib/types";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -33,6 +34,7 @@ export function FileActions({
|
||||
}) {
|
||||
const context = useContext(FileActionsContext);
|
||||
const { t } = useTranslation();
|
||||
const showToast = useToast();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [resolved, setResolved] = useState<FileReferenceMetadata | null>(null);
|
||||
const [loadFailed, setLoadFailed] = useState(false);
|
||||
@@ -71,8 +73,14 @@ export function FileActions({
|
||||
const success = await copyTextToClipboard(value);
|
||||
// A dismissed/reopened menu or another reference owns its own feedback.
|
||||
if (generation !== copyGeneration.current) return;
|
||||
setCopyStatus(success ? "copied" : "failed");
|
||||
if (success) changeOpen(false);
|
||||
if (showToast) {
|
||||
showToast({ message: t(success ? "fileActions.copied" : "fileActions.failed"), tone: success ? "success" : "error",
|
||||
dedupeKey: success ? "copied" : "copy-failed" });
|
||||
} else {
|
||||
setCopyStatus(success ? "copied" : "failed");
|
||||
}
|
||||
// A modal menu hides the rest of the app, including the toast, from assistive technology.
|
||||
if (success || showToast) changeOpen(false);
|
||||
};
|
||||
const openMenu = (target: EventTarget, x: number, y: number) => {
|
||||
point.current = { x, y };
|
||||
|
||||
Reference in new issue
Block a user