Skip to content

Commit

Permalink
Fix time field losing highlight on left/right key
Browse files Browse the repository at this point in the history
  • Loading branch information
probablykasper committed Feb 26, 2024
1 parent f478834 commit a7e7fb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next
- Fix time field sometimes showing a value outside `min`/`max`
- Fix time field losing highlight after pressing left/right arrow keys

## 2.10.1 - 2023 Dec 6
- Fix view not updating when value changes externally with `browseWithoutSelecting`
Expand Down
8 changes: 4 additions & 4 deletions src/lib/TimePicker.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
const delta = e.key === 'ArrowUp' ? 1 : -1
set_value(e.currentTarget, value + delta, true)
e.preventDefault()
select(e.currentTarget)
} else if (e.key === 'ArrowLeft' || e.key === 'ArrowRight' || ':;-,.'.includes(e.key)) {
const field_index = fields.indexOf(e.currentTarget)
const delta = e.key === 'ArrowLeft' ? -1 : 1
const el = fields[field_index + delta]
if (field_index >= 0 && el) {
if (el) {
e.preventDefault()
el.focus()
return
select(el)
}
e.preventDefault()
}
select(e.currentTarget)
}
function get_value(node: HTMLElement) {
Expand Down

0 comments on commit a7e7fb9

Please sign in to comment.