Skip to content

Commit

Permalink
fix: apply changes before input event (#622)
Browse files Browse the repository at this point in the history
* fix: apply selection on input event

* fix: use selection helper for arrows

* fix: apply changes before input event

* test: update tests

* test: reproduce #515
  • Loading branch information
ph-fritsche authored Mar 24, 2021
1 parent 0882e4d commit 5c40248
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 168 deletions.
1 change: 0 additions & 1 deletion src/__tests__/clear.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ test('clears text', () => {
input[value="hello"] - select
input[value="hello"] - keydown: Delete (46)
input[value=""] - input
"{SELECTION}hello{/SELECTION}" -> "{CURSOR}"
input[value=""] - keyup: Delete (46)
`)
})
Expand Down
1 change: 0 additions & 1 deletion src/__tests__/keyboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ it('continue typing with state', () => {
input[value=""] - keydown: F (70) {shift}
input[value=""] - keypress: F (70) {shift}
input[value="F"] - input
"{CURSOR}" -> "F{CURSOR}"
input[value="F"] - keyup: F (70) {shift}
input[value="F"] - keyup: Shift (16)
`)
Expand Down
3 changes: 0 additions & 3 deletions src/__tests__/keyboard/plugin/functional.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ test('backspace to valid value', () => {
input[value=""] - keydown: 5 (53)
input[value=""] - keypress: 5 (53)
input[value="5"] - input
"{CURSOR}" -> "{CURSOR}5"
input[value="5"] - keyup: 5 (53)
input[value="5"] - keydown: e (101)
input[value="5"] - keypress: e (101)
input[value=""] - input
"{CURSOR}5" -> "{CURSOR}"
input[value=""] - keyup: e (101)
input[value=""] - keydown: - (45)
input[value=""] - keypress: - (45)
Expand All @@ -70,7 +68,6 @@ test('backspace to valid value', () => {
input[value=""] - keyup: Backspace (8)
input[value=""] - keydown: Backspace (8)
input[value="5"] - input
"{CURSOR}" -> "{CURSOR}5"
input[value="5"] - keyup: Backspace (8)
`)
})
Expand Down
25 changes: 5 additions & 20 deletions src/__tests__/type-modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ test('a{backspace}', () => {
input[value=""] - keydown: a (97)
input[value=""] - keypress: a (97)
input[value="a"] - input
"{CURSOR}" -> "a{CURSOR}"
input[value="a"] - keyup: a (97)
input[value="a"] - keydown: Backspace (8)
input[value=""] - input
"a{CURSOR}" -> "{CURSOR}"
input[value=""] - keyup: Backspace (8)
`)
})
Expand Down Expand Up @@ -96,7 +94,6 @@ test('{backspace}a', () => {
input[value=""] - keydown: a (97)
input[value=""] - keypress: a (97)
input[value="a"] - input
"{CURSOR}" -> "a{CURSOR}"
input[value="a"] - keyup: a (97)
`)
})
Expand Down Expand Up @@ -125,9 +122,8 @@ test('{backspace} triggers typing the backspace character and deletes the charac
input[value="yo"] - mouseup: Left (0)
input[value="yo"] - click: Left (0)
input[value="yo"] - keydown: Backspace (8)
input[value="o"] - input
"y{CURSOR}o" -> "o{CURSOR}"
input[value="o"] - select
input[value="o"] - input
input[value="o"] - keyup: Backspace (8)
`)
})
Expand Down Expand Up @@ -214,9 +210,8 @@ test('{backspace} deletes the selected range', () => {
input[value="Hi there"] - mouseup: Left (0)
input[value="Hi there"] - click: Left (0)
input[value="Hi there"] - keydown: Backspace (8)
input[value="Here"] - input
"H{SELECTION}i th{/SELECTION}ere" -> "Here{CURSOR}"
input[value="Here"] - select
input[value="Here"] - input
input[value="Here"] - keyup: Backspace (8)
`)
})
Expand Down Expand Up @@ -282,7 +277,6 @@ test('{meta}a{/meta}', () => {
input[value=""] - keydown: a (97) {meta}
input[value=""] - keypress: a (97) {meta}
input[value="a"] - input
"{CURSOR}" -> "a{CURSOR}"
input[value="a"] - keyup: a (97) {meta}
input[value="a"] - keyup: Meta (93)
`)
Expand Down Expand Up @@ -341,7 +335,6 @@ test('{shift}a{/shift}', () => {
input[value=""] - keydown: a (97) {shift}
input[value=""] - keypress: a (97) {shift}
input[value="a"] - input
"{CURSOR}" -> "a{CURSOR}"
input[value="a"] - keyup: a (97) {shift}
input[value="a"] - keyup: Shift (16)
`)
Expand Down Expand Up @@ -374,7 +367,6 @@ test('{capslock}a{capslock}', () => {
input[value=""] - keydown: a (97)
input[value=""] - keypress: a (97)
input[value="a"] - input
"{CURSOR}" -> "a{CURSOR}"
input[value="a"] - keyup: a (97)
input[value="a"] - keydown: CapsLock (20)
input[value="a"] - keyup: CapsLock (20)
Expand Down Expand Up @@ -405,7 +397,6 @@ test('a{enter}', () => {
input[value=""] - keydown: a (97)
input[value=""] - keypress: a (97)
input[value="a"] - input
"{CURSOR}" -> "a{CURSOR}"
input[value="a"] - keyup: a (97)
input[value="a"] - keydown: Enter (13)
input[value="a"] - keypress: Enter (13)
Expand Down Expand Up @@ -673,7 +664,6 @@ test('{space} on an input', () => {
input[value=""] - keydown: (32)
input[value=""] - keypress: (32)
input[value=" "] - input
"{CURSOR}" -> " {CURSOR}"
input[value=" "] - keyup: (32)
`)
})
Expand Down Expand Up @@ -792,7 +782,6 @@ test('{enter} on a textarea', () => {
textarea[value=""] - keydown: Enter (13)
textarea[value=""] - keypress: Enter (13)
textarea[value="\\n"] - input
"{CURSOR}" -> "\\n{CURSOR}"
textarea[value="\\n"] - keyup: Enter (13)
`)
})
Expand Down Expand Up @@ -976,9 +965,8 @@ test('{del} at the start of the input', () => {
input[value="hello"] - mouseup: Left (0)
input[value="hello"] - click: Left (0)
input[value="hello"] - keydown: Delete (46)
input[value="ello"] - input
"{CURSOR}hello" -> "ello{CURSOR}"
input[value="ello"] - select
input[value="ello"] - input
input[value="ello"] - keyup: Delete (46)
`)
})
Expand Down Expand Up @@ -1040,9 +1028,8 @@ test('{del} in the middle of the input', () => {
input[value="hello"] - click: Left (0)
input[value="hello"] - select
input[value="hello"] - keydown: Delete (46)
input[value="helo"] - input
"he{CURSOR}llo" -> "helo{CURSOR}"
input[value="helo"] - select
input[value="helo"] - input
input[value="helo"] - keyup: Delete (46)
`)
})
Expand Down Expand Up @@ -1075,9 +1062,8 @@ test('{del} with a selection range', () => {
input[value="hello"] - click: Left (0)
input[value="hello"] - select
input[value="hello"] - keydown: Delete (46)
input[value="hlo"] - input
"h{SELECTION}el{/SELECTION}lo" -> "hlo{CURSOR}"
input[value="hlo"] - select
input[value="hlo"] - input
input[value="hlo"] - keyup: Delete (46)
`)
})
Expand Down Expand Up @@ -1165,7 +1151,6 @@ test('modifiers will not be closed if skipAutoClose is enabled', () => {
input[value=""] - keydown: a (97) {meta}
input[value=""] - keypress: a (97) {meta}
input[value="a"] - input
"{CURSOR}" -> "a{CURSOR}"
input[value="a"] - keyup: a (97) {meta}
`)
})
Loading

0 comments on commit 5c40248

Please sign in to comment.