Skip to content

Commit

Permalink
Merge pull request #1705 from IgniteUI/PMiteva/Fix-Bug#1590-17.2
Browse files Browse the repository at this point in the history
#1590 Removing stopPropagation from keydown event of the textEditor when maxLength is set
  • Loading branch information
bazal4o authored May 3, 2018
2 parents 6332e55 + 07617b4 commit b6f0dae
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/js/modules/infragistics.ui.editors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2973,8 +2973,8 @@
(e.keyCode > 46 || e.keyCode === 32) && !e.altKey && !e.ctrlKey) {
selection = this._getSelection(this._editorInput[ 0 ]);
if (selection.start === selection.end) {
//P.M. April 25th, 2018 #1590 Remove the keydown.stopPropagation() so that the event can bubble up the DOM tree when the maxLength option is set
e.preventDefault();
e.stopPropagation();
this._sendNotification("warning",
{
optName: "maxLengthWarningMsg",
Expand Down
40 changes: 28 additions & 12 deletions tests/unit/editors/textEditor/tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -1588,11 +1588,13 @@

var testId = 'maxLength is respected';
test(testId, 1, function () {
var $editor;
var $editor, $input;

$editor = $('<input id="maxLengthTest"/>').appendTo("#testBedContainer").igTextEditor({ maxLength : 3 });
typeInInput("abc s", $editor.igTextEditor("field"));
ok($('#maxLengthTest').parents().hasClass("ui-ignotify-warn"), "The notifier is not shown");
$input = $('#maxLengthTest');

$.ig.TestUtil.type("abc s", $input);
ok($input.parents().hasClass("ui-ignotify-warn"), "The notifier is not shown");
$editor.remove();
});

Expand Down Expand Up @@ -1758,6 +1760,29 @@
});
});

var testId = 'Keydown event bubbling when maxLength is set';
test(testId, 1, function () {
var $editor, $input, text = "test", eventRaisedCounter = 0;

$editor = $('<input id="keydownBubblingTest"/>').appendTo("#testBedContainer").igTextEditor({ maxLength : 1 });
$input = $('#keydownBubblingTest');

var keydownEventHandler = function(event) {
var targetId = event.target.id;
if(targetId === 'keydownBubblingTest'){
eventRaisedCounter++;
}
//$(this).off("keydown", keydownEventHandler);
};
$( "body" ).on( "keydown", $input, keydownEventHandler);

$.ig.TestUtil.type(text, $input);
equal(eventRaisedCounter, text.length, "Keydown event should bubble up when the input text exceeds the maxLength");
$( "body" ).off( "keydown", keydownEventHandler);
$editor.remove();
});


// Helper functions
function typeInInput(characters, element) {
var keyDown = jQuery.Event("keydown"),
Expand Down Expand Up @@ -1906,16 +1931,7 @@ <h2 id="qunit-userAgent"></h2>
<input id="issue481"/>
<div id="scrollTest"></div>
</div>

<div id="editorTopList" style="position: absolute; bottom: 30px; left: 30px; width: 400px"></div>








</div>
<div id="editorTopList" style="position: absolute; bottom: 30px; left: 30px; width: 400px"></div>
</body>
Expand Down

0 comments on commit b6f0dae

Please sign in to comment.