This is a migrated thread and some comments may be shown as answers.

Setting focus on client

1 Answer 66 Views
Input
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 14 Oct 2014, 08:25 AM
Hi,

We have a small issue when focus is set on a RadNumericTextBox on the client when using Firefox.
Source:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="input.aspx.vb" Inherits="TestaTredjepartWeb.input" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="s" runat="server">
    </asp:ScriptManager>
    <div>
        <telerik:RadNumericTextBox ID="aa" runat="server" Value="10000000">
        </telerik:RadNumericTextBox><br /><br />
        <asp:Button ID="btnSetFocus" runat="server" Text="Set Focus" OnClientClick="$find('aa').focus(); return false;" />
    </div>
    </form>
</body>
</html>

When pressing the "Set Focus" button, the input gets focus and selects all the text.
So far everything is OK, but when clicking in the textbox after this (to edit the value at the clicked position), nothing happens (seems to select all text again).
But when clicking the texbox a second time, the expected behavior happens (all text is not selected and the cursor is at the clicked position).

This only happens in Firefox, in IE it is working as expected!

Regards
Andreas

1 Answer, 1 is accepted

Sort by
0
Accepted
Konstantin Dikov
Telerik team
answered on 16 Oct 2014, 05:30 PM
Hello Andreas,

I have tested the scenario that you are describing and I was able to replicate the issue in Firefox and Chrome as well. Since this seems to be a bug with the current focus method of the RadInputControl, I will log it in our system, so our developers could further investigate the it and provide a fix in one of our future releases.

For bringing this to our attention you will find your Telerik Points updated.

As a temporarily workaround you could override on of the private methods of the RadInputControl as shown below:
    <script type="text/javascript">
        Telerik.Web.UI.RadInputControl.prototype._onTextBoxFocusHandler =  function (e)
        {
            if (!this.isReadOnly())
            {
                if ($telerik.isIE) {
                    this._allowApplySelection = true;
                }
 
                this._updateStateOnFocus();
            }
 
            // selectiononfocus in Safari/Chrome/FF when tabbing
            if (($telerik.isSafari || $telerik.isFirefox) &&
                         this.get_selectionOnFocus() != Telerik.Web.UI.SelectionOnFocus.None &&
                         this.get_selectionOnFocus() != Telerik.Web.UI.SelectionOnFocus.SelectAll)
            {
                var thisobj = this;
                window.setTimeout(function () { thisobj._triggerDomEvent("mouseup", thisobj._textBoxElement); }, 1);
            }
        }
    </script>
</form>

Please excuse us for any inconvenience caused by this.


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Input
Asked by
Andreas
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or