From 5c9257bf73b44457a2e9356da767b9fd46801525 Mon Sep 17 00:00:00 2001 From: Dade Cook Date: Sun, 21 Jun 2020 08:48:25 -0400 Subject: [PATCH 1/2] fix(type): fix setSelectionRange (#373) Closes #369 Closes #346 --- src/type.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/type.js b/src/type.js index fbf26f98b..8e428ff22 100644 --- a/src/type.js +++ b/src/type.js @@ -61,12 +61,19 @@ async function typeImpl( // The reason we have to do this at all is because it actually *is* // programmatically changed by fireEvent.input, so we have to simulate the // browser's default behavior - if (currentValue() === newValue) { + const value = currentValue() + + if (value === newValue) { setSelectionRangeIfNecessary( currentElement(), newSelectionStart, newSelectionStart, ) + } else { + // If the currentValue is different than the expected newValue and we *can* + // change the selection range, than we should set it to the length of the + // currentValue to ensure that the browser behavior is mimicked. + setSelectionRangeIfNecessary(currentElement(), value.length, value.length) } } From 50e330bc1d7249eea618405f8e3f70e32077ef07 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 21 Jun 2020 06:48:59 -0600 Subject: [PATCH 2/2] docs: add WretchedDade as a contributor (#374) * docs: update README.md * docs: update .all-contributorsrc Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 10 ++++++++++ README.md | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index b13fa3ec4..0dde6e5bc 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -471,6 +471,16 @@ "code", "test" ] + }, + { + "login": "WretchedDade", + "name": "Dade Cook", + "avatar_url": "https://avatars0.githubusercontent.com/u/17183431?v=4", + "profile": "https://github.com/WretchedDade", + "contributions": [ + "code", + "test" + ] } ], "commitConvention": "none", diff --git a/README.md b/README.md index 5de741d34..fab05a7a3 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ [![MIT License][license-badge]][license] -[![All Contributors](https://img.shields.io/badge/all_contributors-47-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-48-orange.svg?style=flat-square)](#contributors-) [![PRs Welcome][prs-badge]][prs] [![Code of Conduct][coc-badge]][coc] @@ -545,6 +545,7 @@ Thanks goes to these people ([emoji key][emojis]):
Dan Kirkham

💻
Johannesklint

📖
Juan Carlos Medina

💻 ⚠️ +
Dade Cook

💻 ⚠️