From d084395198917e3e237a94f5e08c7a7b42b72079 Mon Sep 17 00:00:00 2001 From: plamenamiteva Date: Thu, 26 Apr 2018 16:57:24 +0300 Subject: [PATCH] #1590 removing stopPropagation from the keydown event of the igTextEditor when maxLength is set --- src/js/modules/infragistics.ui.editors.js | 2 +- tests/unit/editors/textEditor/tests.html | 40 ++++++++++++++++------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/js/modules/infragistics.ui.editors.js b/src/js/modules/infragistics.ui.editors.js index 2e955bfae..6a18d9445 100644 --- a/src/js/modules/infragistics.ui.editors.js +++ b/src/js/modules/infragistics.ui.editors.js @@ -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", diff --git a/tests/unit/editors/textEditor/tests.html b/tests/unit/editors/textEditor/tests.html index 86ce50429..5c7aceb7b 100644 --- a/tests/unit/editors/textEditor/tests.html +++ b/tests/unit/editors/textEditor/tests.html @@ -1588,11 +1588,13 @@ var testId = 'maxLength is respected'; test(testId, 1, function () { - var $editor; + var $editor, $input; $editor = $('').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(); }); @@ -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 = $('').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"), @@ -1906,16 +1931,7 @@

-
- - - - - - - -