-
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.
* add email input fixture to show cursor jump * fix cursor jump in email input Co-authored-by: Peter Potapov <dr.potapoff-peter@yandex.ru> * add regression tests to ensure attributes are working Co-authored-by: Peter Potapov <dr.potapoff-peter@yandex.ru>
- Loading branch information
Showing
7 changed files
with
203 additions
and
4 deletions.
There are no files selected for viewing
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
39 changes: 39 additions & 0 deletions
39
fixtures/dom/src/components/fixtures/email-inputs/EmailDisabledAttributesTestCase.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,39 @@ | ||
import Fixture from '../../Fixture'; | ||
|
||
const React = window.React; | ||
|
||
class EmailDisabledAttributesTestCase extends React.Component { | ||
state = {value: 'a@fb.com'}; | ||
onChange = event => { | ||
this.setState({value: event.target.value}); | ||
}; | ||
render() { | ||
return ( | ||
<Fixture> | ||
<div>{this.props.children}</div> | ||
|
||
<div className="control-box"> | ||
<fieldset> | ||
<legend>Controlled</legend> | ||
<input | ||
type="email" | ||
value={this.state.value} | ||
onChange={this.onChange} | ||
/> | ||
<span className="hint"> | ||
{' '} | ||
Value: {JSON.stringify(this.state.value)} | ||
</span> | ||
</fieldset> | ||
|
||
<fieldset> | ||
<legend>Uncontrolled</legend> | ||
<input type="email" defaultValue="" /> | ||
</fieldset> | ||
</div> | ||
</Fixture> | ||
); | ||
} | ||
} | ||
|
||
export default EmailDisabledAttributesTestCase; |
48 changes: 48 additions & 0 deletions
48
fixtures/dom/src/components/fixtures/email-inputs/EmailEnabledAttributesTestCase.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,48 @@ | ||
import Fixture from '../../Fixture'; | ||
|
||
const React = window.React; | ||
|
||
class EmailAttributesTestCase extends React.Component { | ||
state = {value: 'a@fb.com'}; | ||
onChange = event => { | ||
this.setState({value: event.target.value}); | ||
}; | ||
render() { | ||
return ( | ||
<Fixture> | ||
<div>{this.props.children}</div> | ||
|
||
<div className="control-box"> | ||
<fieldset> | ||
<legend>Controlled</legend> | ||
<input | ||
type="email" | ||
pattern=".+@fb.com" | ||
maxlength={17} | ||
multiple={true} | ||
value={this.state.value} | ||
onChange={this.onChange} | ||
/> | ||
<span className="hint"> | ||
{' '} | ||
Value: {JSON.stringify(this.state.value)} | ||
</span> | ||
</fieldset> | ||
|
||
<fieldset> | ||
<legend>Uncontrolled</legend> | ||
<input | ||
type="email" | ||
defaultValue="" | ||
pattern=".+@fb.com" | ||
maxlength={17} | ||
multiple={true} | ||
/> | ||
</fieldset> | ||
</div> | ||
</Fixture> | ||
); | ||
} | ||
} | ||
|
||
export default EmailAttributesTestCase; |
39 changes: 39 additions & 0 deletions
39
fixtures/dom/src/components/fixtures/email-inputs/JumpingCursorTestCase.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,39 @@ | ||
import Fixture from '../../Fixture'; | ||
|
||
const React = window.React; | ||
|
||
class JumpingCursorTestCase extends React.Component { | ||
state = {value: ''}; | ||
onChange = event => { | ||
this.setState({value: event.target.value}); | ||
}; | ||
render() { | ||
return ( | ||
<Fixture> | ||
<div>{this.props.children}</div> | ||
|
||
<div className="control-box"> | ||
<fieldset> | ||
<legend>Controlled</legend> | ||
<input | ||
type="email" | ||
value={this.state.value} | ||
onChange={this.onChange} | ||
/> | ||
<span className="hint"> | ||
{' '} | ||
Value: {JSON.stringify(this.state.value)} | ||
</span> | ||
</fieldset> | ||
|
||
<fieldset> | ||
<legend>Uncontrolled</legend> | ||
<input type="email" defaultValue="" /> | ||
</fieldset> | ||
</div> | ||
</Fixture> | ||
); | ||
} | ||
} | ||
|
||
export default JumpingCursorTestCase; |
68 changes: 68 additions & 0 deletions
68
fixtures/dom/src/components/fixtures/email-inputs/index.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,68 @@ | ||
import FixtureSet from '../../FixtureSet'; | ||
import TestCase from '../../TestCase'; | ||
import JumpingCursorTestCase from './JumpingCursorTestCase'; | ||
import EmailEnabledAttributesTestCase from './EmailEnabledAttributesTestCase'; | ||
import EmailDisabledAttributesTestCase from './EmailDisabledAttributesTestCase'; | ||
|
||
const React = window.React; | ||
|
||
function EmailInputs() { | ||
return ( | ||
<FixtureSet title="Email inputs"> | ||
<TestCase | ||
title="Spaces in email inputs" | ||
description={` | ||
Some browsers are trying to remove spaces from email inputs and after | ||
doing this place cursor to the beginning. | ||
`} | ||
affectedBrowsers="Chrome"> | ||
<TestCase.Steps> | ||
<li>Type space and character</li> | ||
<li>Type character, space, character, delete last character</li> | ||
</TestCase.Steps> | ||
|
||
<TestCase.ExpectedResult>Cursor not moving.</TestCase.ExpectedResult> | ||
|
||
<JumpingCursorTestCase /> | ||
</TestCase> | ||
|
||
<TestCase | ||
title="Attributes enabled" | ||
description={` | ||
Test enabled pattern, maxlength, multiple attributes. | ||
`}> | ||
<TestCase.Steps> | ||
<li>Type after existing text ',b@tt.com'</li> | ||
<li>Try to type spaces after typed text</li> | ||
</TestCase.Steps> | ||
|
||
<TestCase.ExpectedResult> | ||
Spaces not added. When cursor hovered over input, popup "Please match | ||
the requested format." is showed. | ||
</TestCase.ExpectedResult> | ||
|
||
<EmailEnabledAttributesTestCase /> | ||
</TestCase> | ||
|
||
<TestCase | ||
title="Attributes disabled" | ||
description={` | ||
Test disabled maxlength, multiple attributes. | ||
`}> | ||
<TestCase.Steps> | ||
<li>Type after existing text ',b@tt.com'</li> | ||
<li>Try to type spaces after typed text</li> | ||
</TestCase.Steps> | ||
|
||
<TestCase.ExpectedResult> | ||
Spaces are added freely. When cursor hovered over input, popup "A part | ||
following '@' should not contain the symbol ','." is showed. | ||
</TestCase.ExpectedResult> | ||
|
||
<EmailDisabledAttributesTestCase /> | ||
</TestCase> | ||
</FixtureSet> | ||
); | ||
} | ||
|
||
export default EmailInputs; |
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