Skip to content

Commit

Permalink
Fix for setting opacity on mobile (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddenist authored Dec 14, 2023
1 parent e26167c commit 45052f0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions apps/web/src/components/EditableNumericLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ export function EditableNumericLabel(props: {
break
case "Enter":
e.preventDefault()
const value = parseInt(target.innerText)
if (isNaN(value)) {
props.onCancel()
break
}
props.onChange(value)
target.blur()
break
case "Escape":
e.preventDefault()
target.blur()
props.onCancel()
break
default:
Expand Down Expand Up @@ -64,8 +69,14 @@ export function EditableNumericLabel(props: {
})
}

const handleBlur = () => {
props.onCancel()
const handleBlur = (e: FocusEvent) => {
const target = e.target as HTMLSpanElement
const value = parseInt(target.innerText)
if (isNaN(value)) {
props.onCancel()
return
}
props.onChange(value)
}

return (
Expand Down

0 comments on commit 45052f0

Please sign in to comment.