Skip to content

Commit

Permalink
Merge branch 'master' into pr/fix_select_options
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Jun 21, 2020
2 parents 8fadc71 + 50e330b commit 541c2ee
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .all-contributorsrc
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -23,7 +23,7 @@
[![MIT License][license-badge]][license]

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![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-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
[![PRs Welcome][prs-badge]][prs]
[![Code of Conduct][coc-badge]][coc]
Expand Down Expand Up @@ -545,6 +545,7 @@ Thanks goes to these people ([emoji key][emojis]):
<td align="center"><a href="https://twitter.com/herecydev"><img src="https://avatars1.githubusercontent.com/u/11328618?v=4" width="100px;" alt=""/><br /><sub><b>Dan Kirkham</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=herecydev" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Johannesklint"><img src="https://avatars3.githubusercontent.com/u/16774845?v=4" width="100px;" alt=""/><br /><sub><b>Johannesklint</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=Johannesklint" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/juanca"><img src="https://avatars0.githubusercontent.com/u/841084?v=4" width="100px;" alt=""/><br /><sub><b>Juan Carlos Medina</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=juanca" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=juanca" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/WretchedDade"><img src="https://avatars0.githubusercontent.com/u/17183431?v=4" width="100px;" alt=""/><br /><sub><b>Dade Cook</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=WretchedDade" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=WretchedDade" title="Tests">⚠️</a></td>
</tr>
</table>

Expand Down
9 changes: 8 additions & 1 deletion src/type.js
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 541c2ee

Please sign in to comment.