diff --git a/.all-contributorsrc b/.all-contributorsrc index b13fa3ec..0dde6e5b 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 5de741d3..fab05a7a 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

💻 ⚠️ diff --git a/src/type.js b/src/type.js index fbf26f98..8e428ff2 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) } }