Skip to content

Commit

Permalink
NumberInput: holding arrow up-down makes the updates transient (#6378)
Browse files Browse the repository at this point in the history
**Problem:**
The `NumberInput` component which is used all over the inspector did not
properly handle when the arrow up/down keys were pressed and held.

**Fix:**
It _looks like_ this did not work in the last 4 years! Amazingly, all of
the proper handling _was_ wired in, but then instead of passing in a
true flag, the code passed in a false flag, which made every event
non-transient. Weird!

**Commit Details:**
- Just passing in `true` as `incrementBy`'s transient parameter
  • Loading branch information
balazsbajorics authored Sep 23, 2024
1 parent 0a6db9d commit 4f2faf2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions editor/src/uuiui/inputs/number-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,10 @@ export const NumberInput = React.memo<NumberInputProps>(
const onKeyDown = React.useCallback(
(e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === 'ArrowUp') {
updateValue(incrementBy(stepSize, e.shiftKey, false))
updateValue(incrementBy(stepSize, e.shiftKey, true))
} else if (e.key === 'ArrowDown') {
e.preventDefault()
updateValue(incrementBy(-stepSize, e.shiftKey, false))
updateValue(incrementBy(-stepSize, e.shiftKey, true))
} else if (e.key === 'Enter' || e.key === 'Escape') {
e.nativeEvent.stopImmediatePropagation()
e.preventDefault()
Expand Down

0 comments on commit 4f2faf2

Please sign in to comment.