summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-03-08 21:03:13 +0000
committerAndrej Mihajlov <and@codeispoetry.ru>2017-03-08 21:03:13 +0000
commit6f306338b5d0e687e769bc4961798f2a4986730c (patch)
tree6be0f859ab55f84cd19886be356410a618bae6d9
parenta0d3b2a3acc0db2a947b0a10767bf568da06205a (diff)
downloadmullvadvpn-6f306338b5d0e687e769bc4961798f2a4986730c.tar.xz
mullvadvpn-6f306338b5d0e687e769bc4961798f2a4986730c.zip
Handle cut
-rw-r--r--app/components/AccountInput.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/components/AccountInput.js b/app/components/AccountInput.js
index f8de905b0f..05d975effa 100644
--- a/app/components/AccountInput.js
+++ b/app/components/AccountInput.js
@@ -52,6 +52,7 @@ export default class AccountInput extends Component {
onKeyUp={ ::this.onKeyUp }
onKeyDown={ ::this.onKeyDown }
onPaste={ ::this.onPaste }
+ onCut={ ::this.onCut }
ref={ ::this.onRef }
{ ...props } />
);
@@ -215,6 +216,27 @@ export default class AccountInput extends Component {
});
}
+ onCut(e) {
+ const { value, selectionRange } = this.state;
+
+ e.preventDefault();
+
+ // range is not empty?
+ if(selectionRange[0] !== selectionRange[1]) {
+ const result = this.remove(value, selectionRange);
+ const domSelectionRange = this.toDomSelection(value, selectionRange);
+ const slice = e.target.value.slice(domSelectionRange[0], domSelectionRange[1]);
+
+ e.clipboardData.setData('text', slice);
+
+ this.setState(result, () => {
+ if(this.props.onChange) {
+ this.props.onChange(result.value);
+ }
+ });
+ }
+ }
+
onRef(ref) {
if(!ref) { return; }
const { value, selectionRange } = this.state;