Skip to content

Commit 0a2823b

Browse files
fix(browser): prevent duplicate extractions on inspect click
1 parent 757d704 commit 0a2823b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

crates/tauri-app/frontend/src/components/browser/BrowserPanel.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function BrowserPanel(props: Props) {
1414
const [currentUrl, setCurrentUrl] = createSignal(urlInput());
1515
const [inspecting, setInspecting] = createSignal(false);
1616
const [loading, setLoading] = createSignal(false);
17+
let extractPending = false;
1718
let canvasRef: HTMLCanvasElement | undefined;
1819
let containerRef: HTMLDivElement | undefined;
1920
let img = new Image();
@@ -54,7 +55,8 @@ export function BrowserPanel(props: Props) {
5455
setLoading(false);
5556
break;
5657
case "extraction":
57-
if (p.html) {
58+
if (p.html && extractPending) {
59+
extractPending = false;
5860
const content = `<!-- From ${currentUrl()} ${p.selector || ""} -->\n${p.html}\n\n/* Computed styles */\n${p.css || "{}"}`;
5961
setStore("attachments", (prev) => [...prev, {
6062
id: crypto.randomUUID(),
@@ -100,10 +102,8 @@ export function BrowserPanel(props: Props) {
100102
function handleClick(e: MouseEvent) {
101103
const { x, y } = toVP(e);
102104
if (inspecting()) {
103-
// Click selects element, then extract
104-
ipc.browserClick(props.threadId, x, y).then(() => {
105-
setTimeout(() => ipc.browserExtract(props.threadId), 100);
106-
});
105+
extractPending = true;
106+
ipc.browserExtract(props.threadId);
107107
} else {
108108
ipc.browserClick(props.threadId, x, y);
109109
}

0 commit comments

Comments
 (0)