Skip to content

Commit e2b4c6e

Browse files
committed
Apply minor polish to EditableNumber
1 parent a0e4226 commit e2b4c6e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib/EditableNumber.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
if (value > max) value = max
2323
})
2424
25-
function select(e: FocusEvent) {
25+
// Select all the text when the input is focused
26+
function onfocus(e: FocusEvent) {
2627
const range = document.createRange()
2728
range.selectNodeContents(e.target as HTMLElement)
2829
const sel = window.getSelection()!
@@ -51,8 +52,8 @@
5152
role="none"
5253
contenteditable="true"
5354
bind:innerText={serialise, deserialise}
54-
onfocus={select}
5555
onkeypress={e => isNaN(parseInt(e.key)) && e.preventDefault()}
56+
{onfocus}
5657
{onwheel}
5758
></div>
5859
{#if children}

0 commit comments

Comments
 (0)