Skip to content

Commit

Permalink
Merge pull request DevExpress#120 from MikhailTymchukDX/htmleditorext…
Browse files Browse the repository at this point in the history
…ender-focus

Resolve DevExpress#109
  • Loading branch information
MikhailTymchukDX committed May 27, 2016
2 parents 101e8a8 + d53bf29 commit e4ae8a7
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
<asp:Content ContentPlaceHolderID="TestSuite" runat="server">
<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>

<asp:UpdatePanel ID="LocalUpdatePanel" runat="server">
<ContentTemplate>
<asp:Button ID="UpdatePanelButton" runat="server" Text="Update panel" ClientIDMode="Static" />
</ContentTemplate>
</asp:UpdatePanel>

<asp:TextBox runat="server" ID="SimpleTextBox" ClientIDMode="Static" />

<asp:TextBox runat="server"
ID="Target"
Width="500"
Expand Down Expand Up @@ -107,7 +116,9 @@
describe("HtmlEditorExtender", function() {
var HTML_EDITOR_EXTENDER_CLIENT_ID = "<%= TargetExtender.ClientID %>",
HTML_EDITOR_EXTENDER_SANITIZED_CLIENT_ID = "<%= TargetExtenderSanitized.ClientID %>";
HTML_EDITOR_EXTENDER_SANITIZED_CLIENT_ID = "<%= TargetExtenderSanitized.ClientID %>",
SIMPLE_TEXTBOX_CLIENT_ID = "<%= SimpleTextBox.ClientID %>",
UPDATE_PANEL_BUTTON_CLIENT_ID = "<%= UpdatePanelButton.ClientID %>";
var HTML_EDITOR_COLOR_PICKER_CONTAINER_CLASS_NAME = "ajax__colorPicker";
Expand Down Expand Up @@ -733,6 +744,25 @@
expect($container.find(".ajax__html_editor_extender_Copy").length).toBeTruthy();
expect($container.find(".ajax__html_editor_extender_Paste").length).toBeTruthy();
});
it("correctly loses editable div focus", function(done) {
var wrapper = new HtmlEditorWrapper(this.extender);
wrapper.setContent("abc");
var textbox = $("#" + SIMPLE_TEXTBOX_CLIENT_ID);
textbox.focus();
var endRequestHandler = function() {
expect(document.activeElement).toEqual(textbox.get(0));
done();
}
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
var button = $("#" + UPDATE_PANEL_BUTTON_CLIENT_ID);
button.click();
});
});
</script>

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions AjaxControlToolkit/Scripts/HtmlEditorExtender.js
Original file line number Diff line number Diff line change
Expand Up @@ -753,27 +753,6 @@ Sys.Extended.UI.HtmlEditorExtenderBehavior.prototype = {
},

_editableDiv_submit: function() {
var char = 0,
selection = null;

setTimeout(function() {
if(this._editableDiv != null)
this._editableDiv.focus();
}, 0);

if(Sys.Browser.agent != Sys.Browser.Firefox) {
if(document.selection) {
selection = document.selection.createRange();
selection.moveStart('character', char);
selection.select();
} else {
selection = window.getSelection();

if(this._editableDiv.firstChild !== null)
selection.collapse(this._editableDiv.firstChild, char);
}
}

this._textbox._element.value = this._encodeHtml();
},

Expand Down
Loading

0 comments on commit e4ae8a7

Please sign in to comment.