Skip to content

Commit 5d76ea8

Browse files
authored
Fix autocomplete arrows behavior (#139)
* fix(dropdown): keep suggestion list open The suggestion list should stay open even though you are pressing up or down arrow. close #138 * Update Cypress
1 parent b1209c1 commit 5d76ea8

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

cypress/integration/textarea.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,5 +317,10 @@ describe("React Textarea Autocomplete", () => {
317317
.click();
318318
cy.get(".rta__textarea").should("have.value", "This is test (");
319319
});
320+
321+
it("arrow down and up should not stop autocomplete when dropdown is open", () => {
322+
cy.get(".rta__textarea").type("This is test :cro{downarrow}w{enter}");
323+
cy.get(".rta__textarea").should("have.value", "This is test 👑");
324+
});
320325
});
321326
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"babel-loader": "8.0.4",
5353
"babel-preset-react-app": "6.1.0",
5454
"css-loader": "2.0.1",
55-
"cypress": "3.1.3",
55+
"cypress": "3.1.5",
5656
"enzyme": "^3.7.0",
5757
"enzyme-adapter-react-16": "^1.6.0",
5858
"enzyme-to-json": "^3.3.4",

src/Textarea.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ class ReactTextareaAutocomplete extends React.Component<
323323
switch (code) {
324324
case KEY_CODES.UP:
325325
case KEY_CODES.DOWN:
326+
if (!this._isAutocompleteOpen()) {
327+
this.lastTrigger = this.getCaretPosition() - 1;
328+
}
329+
break;
326330
case KEY_CODES.LEFT:
327331
case KEY_CODES.RIGHT:
328332
this.lastTrigger = this.getCaretPosition() - 1;

yarn.lock

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,24 +1049,19 @@
10491049
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.0.tgz#ea6dcbddbc5b584c83f06c60e82736d8fbb0c235"
10501050
integrity sha512-3TUHC3jsBAB7qVRGxT6lWyYo2v96BMmD2PTcl47H25Lu7UXtFH/2qqmKiVrnel6Ne//0TFYf6uvNX+HW2FRkLQ==
10511051

1052-
"@types/sinon-chai@2.7.29":
1053-
version "2.7.29"
1054-
resolved "https://registry.yarnpkg.com/@types/sinon-chai/-/sinon-chai-2.7.29.tgz#4db01497e2dd1908b2bd30d1782f456353f5f723"
1055-
integrity sha512-EkI/ZvJT4hglWo7Ipf9SX+J+R9htNOMjW8xiOhce7+0csqvgoF5IXqY5Ae1GqRgNtWCuaywR5HjVa1snkTqpOw==
1052+
"@types/sinon-chai@3.2.2":
1053+
version "3.2.2"
1054+
resolved "https://registry.yarnpkg.com/@types/sinon-chai/-/sinon-chai-3.2.2.tgz#5cfdbda70bae30f79a9423334af9e490e4cce793"
1055+
integrity sha512-5zSs2AslzyPZdOsbm2NRtuSNAI2aTWzNKOHa/GRecKo7a5efYD7qGcPxMZXQDayVXT2Vnd5waXxBvV31eCZqiA==
10561056
dependencies:
10571057
"@types/chai" "*"
10581058
"@types/sinon" "*"
10591059

1060-
"@types/sinon@*":
1060+
"@types/sinon@*", "@types/[email protected]":
10611061
version "7.0.0"
10621062
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-7.0.0.tgz#84e707e157ec17d3e4c2a137f41fc3f416c0551e"
10631063
integrity sha512-kcYoPw0uKioFVC/oOqafk2yizSceIQXCYnkYts9vJIwQklFRsMubTObTDrjQamUyBRd47332s85074cd/hCwxg==
10641064

1065-
1066-
version "4.0.0"
1067-
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-4.0.0.tgz#9a93ffa4ee1329e85166278a5ed99f81dc4c8362"
1068-
integrity sha512-cuK4xM8Lg2wd8cxshcQa8RG4IK/xfyB6TNE6tNVvkrShR4xdrYgsV04q6Dp6v1Lp6biEFdzD8k8zg/ujQeiw+A==
1069-
10701065
"@types/sizzle@*":
10711066
version "2.3.2"
10721067
resolved "https://registry.yarnpkg.com/@types/sizzle/-/sizzle-2.3.2.tgz#a811b8c18e2babab7d542b3365887ae2e4d9de47"
@@ -2849,10 +2844,10 @@ cyclist@~0.2.2:
28492844
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640"
28502845
integrity sha1-GzN5LhHpFKL9bW7WRHRkRE5fpkA=
28512846

2852-
2853-
version "3.1.3"
2854-
resolved "https://registry.yarnpkg.com/cypress/-/cypress-3.1.3.tgz#f6253e2428c9f76e0541440b959b6282d1757467"
2855-
integrity sha512-ZusTQffKBVrLDvcxEinymTH0iCUL7hM1m6q9X+557wDtpd6S4et330QQE1IW10Pnyp+vYIHpkWxDm43B9G14nA==
2847+
2848+
version "3.1.5"
2849+
resolved "https://registry.yarnpkg.com/cypress/-/cypress-3.1.5.tgz#5227b2ce9306c47236d29e703bad9055d7218042"
2850+
integrity sha512-jzYGKJqU1CHoNocPndinf/vbG28SeU+hg+4qhousT/HDBMJxYgjecXOmSgBX/ga9/TakhqSrIrSP2r6gW/OLtg==
28562851
dependencies:
28572852
"@cypress/listr-verbose-renderer" "0.4.1"
28582853
"@cypress/xvfb" "1.2.3"
@@ -2864,8 +2859,8 @@ [email protected]:
28642859
"@types/lodash" "4.14.87"
28652860
"@types/minimatch" "3.0.3"
28662861
"@types/mocha" "2.2.44"
2867-
"@types/sinon" "4.0.0"
2868-
"@types/sinon-chai" "2.7.29"
2862+
"@types/sinon" "7.0.0"
2863+
"@types/sinon-chai" "3.2.2"
28692864
bluebird "3.5.0"
28702865
cachedir "1.3.0"
28712866
chalk "2.4.1"
@@ -2883,7 +2878,7 @@ [email protected]:
28832878
is-installed-globally "0.1.0"
28842879
lazy-ass "1.6.0"
28852880
listr "0.12.0"
2886-
lodash "4.17.10"
2881+
lodash "4.17.11"
28872882
log-symbols "2.2.0"
28882883
minimist "1.2.0"
28892884
moment "2.22.2"
@@ -6231,26 +6226,26 @@ lodash.sortby@^4.7.0:
62316226
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
62326227
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
62336228

6234-
[email protected], lodash@^4.13.1:
6235-
version "4.17.10"
6236-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
6237-
integrity sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==
6229+
[email protected].11, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.5, lodash@^4.2.0:
6230+
version "4.17.11"
6231+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
6232+
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
62386233

62396234
62406235
version "4.17.9"
62416236
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.9.tgz#9c056579af0bdbb4322e23c836df13ef2b271cb7"
62426237
integrity sha512-vuRLquvot5sKUldMBumG0YqLvX6m/RGBBOmqb3CWR/MC/QvvD1cTH1fOqxz2FJAQeoExeUdX5Gu9vP2EP6ik+Q==
62436238

6239+
lodash@^4.13.1:
6240+
version "4.17.10"
6241+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
6242+
integrity sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==
6243+
62446244
lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.3.0:
62456245
version "4.17.4"
62466246
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
62476247
integrity sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=
62486248

6249-
lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.5, lodash@^4.2.0:
6250-
version "4.17.11"
6251-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
6252-
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
6253-
62546249
[email protected], log-symbols@^2.2.0:
62556250
version "2.2.0"
62566251
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.2.0.tgz#5740e1c5d6f0dfda4ad9323b5332107ef6b4c40a"

0 commit comments

Comments
 (0)