-
Notifications
You must be signed in to change notification settings - Fork 47.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not set selection when prior selection is undefined (#12062)
`restoreSelection` did not account for input elements that have changed type after the commit phase. The new `text` input supported selection but the old `email` did not and `setSelection` was incorrectly trying to restore `null` selection state. We also extend input type check in selection capabilities to cover cases where input type is `search`, `tel`, `url`, or `password`.
- Loading branch information
1 parent
5cd5f63
commit bc7d887
Showing
4 changed files
with
83 additions
and
26 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
fixtures/dom/src/components/fixtures/text-inputs/ReplaceEmailInput.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Fixture from '../../Fixture'; | ||
|
||
const React = window.React; | ||
|
||
class ReplaceEmailInput extends React.Component { | ||
state = { | ||
formSubmitted: false, | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Fixture> | ||
<form | ||
className="control-box" | ||
onSubmit={event => { | ||
event.preventDefault(); | ||
this.setState({formSubmitted: true}); | ||
}}> | ||
<fieldset> | ||
<legend>Email</legend> | ||
{!this.state.formSubmitted ? ( | ||
<input type="email" /> | ||
) : ( | ||
<input type="text" disabled={true} /> | ||
)} | ||
</fieldset> | ||
</form> | ||
</Fixture> | ||
); | ||
} | ||
} | ||
|
||
export default ReplaceEmailInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters