From f15a305b286f31d81241d833c464ece0cdfacae2 Mon Sep 17 00:00:00 2001 From: Justin Shetty Date: Tue, 4 Feb 2025 01:24:34 +0900 Subject: [PATCH] blur file input (#22) --- src/GraphLoader.tsx | 4 ++++ src/SolutionLoader.tsx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/GraphLoader.tsx b/src/GraphLoader.tsx index 7db9ea7..e3cc02d 100644 --- a/src/GraphLoader.tsx +++ b/src/GraphLoader.tsx @@ -16,6 +16,10 @@ function GraphLoader({ onGraphChange }: GraphLoaderProps) { newValue.text().then((text) => { const g = new Graph(text); onGraphChange(g); + // Blur (remove focus from) the file input + if (document.activeElement instanceof HTMLElement) { + document.activeElement.blur(); + } }); } diff --git a/src/SolutionLoader.tsx b/src/SolutionLoader.tsx index 93bb8d8..26ff0be 100644 --- a/src/SolutionLoader.tsx +++ b/src/SolutionLoader.tsx @@ -15,6 +15,10 @@ function SolutionLoader({ onSolutionChange }: SolutionLoaderProps) { if (newValue) { newValue.text().then((text) => { onSolutionChange(parseSolution(text)); + // Blur (remove focus from) the file input + if (document.activeElement instanceof HTMLElement) { + document.activeElement.blur(); + } }); } }