From f9d915378b9f6b7a64e5879d54e1e903800d3dab Mon Sep 17 00:00:00 2001 From: Lauri Vuorela Date: Thu, 30 May 2024 03:45:46 +0200 Subject: [PATCH] change onClick to onFocus, with a slight delay for safari (#144) * change onClick to onFocus, with a slight delay for safari * typo * fix variable name * Fix style --------- Co-authored-by: Sebastien Castiel --- src/components/expense-form.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/expense-form.tsx b/src/components/expense-form.tsx index df5563d..f68dc50 100644 --- a/src/components/expense-form.tsx +++ b/src/components/expense-form.tsx @@ -326,7 +326,11 @@ export function ExpenseForm({ onChange={(event) => onChange(enforceCurrencyPattern(event.target.value)) } - onClick={(e) => e.currentTarget.select()} + onFocus={(e) => { + // we're adding a small delay to get around safaris issue with onMouseUp deselecting things again + const target = e.currentTarget + setTimeout(() => target.select(), 1) + }} {...field} />