Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
leading: '',
custom: '',
changing: '',
phone: '',
pattern: '1111 1111'
}
},
Expand Down Expand Up @@ -112,6 +113,10 @@ <h1><code>&lt;<a href="https://github.com/insin/react-maskedinput">MaskedInput</
<label htmlFor="plate">License Plate:</label>
<MaskedInput mask="AAA 1111" name="plate" id="plate" onChange={this._onChange} placeholder="ABC 1234"/>
</div>
<div className="form-field">
<label htmlFor="phone">Phone Number:</label>
<MaskedInput mask="(111) 111-1111" name="phone" id="phone" onChange={this._onChange} placeholder="(999) 999-9999"/>
</div>
<p>Mask placeholder characters can be escaped with a leading <code>\</code> to use them as static contents:</p>
<div className="form-field">
<label htmlFor="escaped">Escaped:</label>
Expand Down
9 changes: 9 additions & 0 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ var MaskedInput = React.createClass({
this.mask.selection.end = this.mask.selection.start + sizeDiff
this.mask.backspace()
}
this.mask.setValue(e.target.value);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the value here expedcted to be what is set as e.target.value on L#153?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like it. @axelson would you mind chiming in?

var value = this._getDisplayValue()
e.target.value = value
if (value) {
Expand Down Expand Up @@ -146,6 +147,14 @@ var MaskedInput = React.createClass({
setTimeout(this._updateInputSelection, 0)
this.props.onChange(e)
}
else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you educate me on why the if (this.mask.paste(e.clipboardData.getData('Text')) {...} part just before this block returns falsy and falls through to this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The falsy return happens here https://github.com/insin/inputmask-core/blob/master/lib/index.js#L374-L393 on line 391. I'm not exactly sure what that means, but I can dive into it more if need be.

this.mask.setValue(e.clipboardData.getData('Text'));
var value = this._getDisplayValue()
e.target.value = value
if (value) {
this._updateInputSelection()
}
}
},

_getDisplayValue() {
Expand Down