Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ It's pretty self explanatory (click the "edit" icon to edit, etc.), but there ar
- `Escape` to cancel editing
- When clicking the "clipboard" icon, holding down `Cmd/Ctrl` will copy the *path* to the selected node rather than its value
- When opening/closing a node, hold down "Alt/Option" to open/close *all* child nodes at once
- For Number inputs, arrow-up and down keys will increment/decrement the value

## Props overview

Expand Down
17 changes: 15 additions & 2 deletions src/ValueNodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,21 @@ export const NumberValue: React.FC<InputProps & { value: number }> = ({
}) => {
const { getStyles } = useTheme()
const handleKeyPress = (e: React.KeyboardEvent) => {
if (e.key === 'Enter') handleEdit()
else if (e.key === 'Escape') handleCancel()
switch (e.key) {
case 'Enter':
handleEdit()
break
case 'Escape':
handleCancel()
break
case 'ArrowUp':
e.preventDefault()
setValue((prev) => Number(prev) + 1)
break
case 'ArrowDown':
e.preventDefault()
setValue((prev) => Number(prev) - 1)
}
}

const validateNumber = (input: string) => {
Expand Down