On closing the RadSpell dialog box I get the following javascript error: "Error: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.

9 posts, 1 answers
  1. Abhay Jain
    Abhay Jain avatar
    11 posts
    Member since:
    Jul 2009

    Posted 23 Dec 2010 Link to this post

    Hello,

    I am observing a typical behavior on closing the RadSpell dialog box.

    Steps to replicate the issue:
    1. Open the RadSpell dialog box.
    2. Ensure that the text box that it is trying to spell check has at least one invalid text entry (as per the dictionary used).
    3. Now, close the spell check dialog box before it shows the valid suggestions for the incorrect entry (as per the dictionary used).
    4. The browser would then show the following java script error: "Error: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."
    I know why this is happening. Reason is simple: The HTML element that the RadSpell is trying to bring focus is no more visible because I closed the dialog box. Please let me know if I can tweak something somewhere to avoid the above thing from happening.

    I am using RadControls Q3 2008. I have tried the above scenario on the IE8 browser.

    Thanks.
    ~Abhay
  2. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 24 Dec 2010 Link to this post

    Hello Abhay Jain,

    You are using a very old version of RadSpell. Are you able to reproduce the problem with the latest one in the following live demo: http://demos.telerik.com/aspnet-ajax/spell/examples/whatsnew/defaultcs.aspx?

    If the problem is not reproducible, our recommendation is to upgrade to Q3 2010 SP1 (ver. 2010.3.1215).

    Best regards,
    Rumen
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Abhay Jain
    Abhay Jain avatar
    11 posts
    Member since:
    Jul 2009

    Posted 24 Dec 2010 Link to this post

    Thanks for replying Rumen.
    1. I tried to reproduce the issue using the live demo. The thing is, on the live demo page, the time that it takes to perform the spell check and to show the suggestions is so less that I can't close the dialog box before the suggestions are displayed. This is a vital step to replicate the issue. Moreover, we're not using the English dictionary. Instead, we're employing a medical dictionary.
    2. Due to the nature of the project and it being live and running, we can't update the version of Telerik RadControls as we're wary of the adverse effects, that upgrading would have.  Kindly let me know if there is any other way of eliciting support for the older version.
    Thanks.
    ~Abhay
  5. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 29 Dec 2010 Link to this post

    Hi Abhay,

    My suggestion is to hide the close [X] titlebar button on the Spell dialog and prevent the dialog closing from it. You can do that using the following CSS class:

    <head runat="server">
        <title></title>
        <style type="text/css">
            .rwCloseButton { display: none !important; }
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager" runat="server"></asp:ScriptManager>
            <telerik:RadSpell ID="RadSpell1" runat="server" ControlsToCheck="TextBox1" />
            <asp:TextBox ID="TextBox1" runat="server">das dasdas das asd</asp:TextBox>
        </form>
    </body>
    </html>



    Best regards,
    Rumen
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  6. Abhay Jain
    Abhay Jain avatar
    11 posts
    Member since:
    Jul 2009

    Posted 29 Dec 2010 Link to this post

    Thanks Rumen.

    I understand what you're saying. But there should be a way for the user to close the dialog once the suggestions are displayed. How would the user close the dialog otherwise?

    (1) Ideal way should have been, to extend your suggestion, to hide the CLOSE button and show it immediately after the suggestions are listed. Is there any client side event that is generated when suggestions are displayed that I could handle to hide/show the CLOSE button?

    (2) Another alternative can be: on the ClientDialogClosing event we stop the spell check completely thus preventing it to bring focus to the invisible suggestions that is the cause for the java script error.
  7. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 31 Dec 2010 Link to this post

    Hi Abhay,

    The provided css class just hides the x button on top right corner of RadSpell dialog. There is another close button in the RadSpell dialog itself, which your user can click to close the dialog. This inner close button is loaded with the rest of the dialog content, so your users will be unable to click it before the full load of the dialog.

    You can see how the suggestion works in the following video: http://screencast.com/t/pOAqLgiV.

    Is the problem reproducible with the internal Cancel button?

    The available events for RadSpell are listed here: http://www.telerik.com/help/aspnet-ajax/spell_clientevents.html.

    Best regards,
    Rumen
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  8. Abhay Jain
    Abhay Jain avatar
    11 posts
    Member since:
    Jul 2009

    Posted 27 Jan 2011 Link to this post

    Hi Rumen,

    The problem that our users face is reproducible with both the Cancel and Close buttons.

    The issue is not that the users click the Cancel/Close button before the dialog gets loaded completely. The problem happens when the spell check has begun and then the user closes the dialog. Due to this, when the spell check web service returns with the suggestions, there is no place (since the dialog was closed/hidden) for them to be displayed. Now, at this point if the JS code tries to bring the focus to the first suggestion, the browser cribs because the control that is being tried to focus upon is hidden.

    Thus as I suggested in one of my earlier posts, I can only think of the following ways to avert the problem but due to lack of proper events, I am not able to even achieve that.

    (1) Ideal way should have been, to extend your suggestion, to hide the CLOSE button and show it immediately after the suggestions are listed. Is there any client side event that is generated when suggestions are displayed that I could handle to hide/show the CLOSE button?

    (2) Another alternative can be: on the ClientDialogClosing event we stop the spell check completely thus preventing it to bring focus to the invisible suggestions that is the cause for the java script error.

    Thanks for patiently listening to me.
  9. Answer
    Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 01 Feb 2011 Link to this post

    Hi Abhay,

    Can you please try the following code which will hide the Close button (inside the RadSpell dialog) when the dialog opens and display the button after three seconds:

    <telerik:RadSpell ID="RadSpell1" runat="server" ControlsToCheck="TextBox1" OnClientCheckStarted="OnClientCheckStarted" />
    <asp:TextBox ID="TextBox1" runat="server">dassdas dasdasdas dasdas</asp:TextBox>
    <script type="text/javascript">
        function OnClientCheckStarted(spell) {
            setTimeout(function () {
                var cancelButton = spell._dialogOpener._dialogContainers.SpellCheckDialog.get_contentFrame().contentWindow.document.getElementById("dialogControl_Cancel");
                cancelButton.parentNode.style.display = "none";
                setTimeout(function () {
                    if (!$telerik.isIE) {
                        cancelButton.parentNode.parentNode.style.display = "block";
                    }
                    else cancelButton.parentNode.style.display = "block";
                }, 3000);
            }, 350);
        }
    </script>

    You can change the time values of the setTimeout functions, if needed.

    Greetings,
    Rumen
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  10. Abhay Jain
    Abhay Jain avatar
    11 posts
    Member since:
    Jul 2009

    Posted 02 Feb 2011 Link to this post

    Rumen.

    Hurray! It worked. Thanks!

    In absence of standard (and documented) way of handling this, I guess, this is the best we can do to handle the problem. Only if there were events that got fired at the beginning of spell check (call to spell check web service) and at the end (when the web service returns with the suggestions). Currently, ClientCheckStarted is fired when the spell checker dialog box opens and ClientCheckFinished is raised when dialog box closes and that too only if the user has either corrected or ignored each of the spell errors (rendering the ClientCheckFinished event useless in my scenario).

    As you mentioned in your response, I had to change the time for the external setTimeout call to get it working. With 350ms, it wasn't able to find out the DOM element for 'Cancel' button, at least on my local machine. I will have to deploy the solution and see if the delay that I've set currently (1second instead of 350ms) is fine on every user's machine.

    I hope Telerik has taken care of the issue that I faced, in later releases.

    Once again, thanks Rumen for following this thread very earnestly and for your time. Really appreciate that!

    ~Abhay
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017