Skip to content

Commit

Permalink
Fix Ctrl+X behavior
Browse files Browse the repository at this point in the history
Cutting text (Ctrl+X) from a read-only <input> field no longer removes the text.

Fixes nosir#549
  • Loading branch information
kalmancsaba committed Dec 4, 2020
1 parent e3fa6f3 commit 65bdb44
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
4 changes: 3 additions & 1 deletion dist/cleave-angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ return /******/ (function(modules) { // webpackBootstrap
onCut: function (e) {
if (!Cleave.Util.checkFullSelection(this.element.value)) return;
this.copyClipboardData(e);
this.onInput('');
if (!this.element.readonly) {
this.onInput('');
}
},

onCopy: function (e) {
Expand Down
2 changes: 1 addition & 1 deletion dist/cleave-angular.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/cleave-esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,9 @@ Cleave.prototype = {
onCut: function (e) {
if (!Cleave.Util.checkFullSelection(this.element.value)) return;
this.copyClipboardData(e);
this.onInput('');
if (!this.element.readonly) {
this.onInput('');
}
},

onCopy: function (e) {
Expand Down
2 changes: 1 addition & 1 deletion dist/cleave-esm.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/cleave.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ return /******/ (function(modules) { // webpackBootstrap
onCut: function (e) {
if (!Cleave.Util.checkFullSelection(this.element.value)) return;
this.copyClipboardData(e);
this.onInput('');
if (!this.element.readonly) {
this.onInput('');
}
},

onCopy: function (e) {
Expand Down
2 changes: 1 addition & 1 deletion dist/cleave.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion src/Cleave.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ Cleave.prototype = {
onCut: function (e) {
if (!Cleave.Util.checkFullSelection(this.element.value)) return;
this.copyClipboardData(e);
this.onInput('');
if (!this.element.readonly) {
this.onInput('');
}
},

onCopy: function (e) {
Expand Down

0 comments on commit 65bdb44

Please sign in to comment.