Keep focus on validator fails

3 posts, 0 answers
  1. Bart
    Bart avatar
    2 posts
    Member since:
    May 2015

    Posted 13 May 2015 Link to this post

    I have a client who requested when a kendo control can't validate, the focus is kept on the invalidate object.
    This is something that to my knowledge isn't supported by default by the components.

    So i've tried something like writing a validation rule like this (raw example, won't work)

    rule :function(input){
        var isValid = false;
         //some code to do validation
         if(!isValid){
            var kendoComponent = $(input.id).data("kendoCombobox");
            input.focus();
        }
        return isValid
    }

     

    The problem i'm having is that before input.focus(), the next component shortly ahs focus, and by setting the focus to the invalidate compinent, the next components validation is triggered as well. The next component says it's invalid, and thus calls for the focus. Creating an endless loop between these 2 components each asking for focus.

    To try and counter this, i've kept a dominantfield status. If the validation is triggerd for a none dominant component, that component should always say "i'm valid" thus not calling for focus. As far is i can determine following stacktraces and output logging, this code is working, though somewhere focus is still being called on the second component causing an infinite loop. while the custom code i wrote in my validation ruls never call .focus() on the second component. I can't figure out why the components would still keep trying to get focus. or why in the telerik js code, an infite loop would be created.

    Any thoughts on why this infinte loop could be created, or any input as how else this functionality can be obtained?

  2. Bart
    Bart avatar
    2 posts
    Member since:
    May 2015

    Posted 13 May 2015 in reply to Bart Link to this post

    Oké, in the mean time, i've been able to try some more things out. I've come to a state where my code to gain focus is absolutly not the issue anymore. the .focus() function is no longer part of my validation rules.

    However i can still reproduce a situation where 2 telerik controls try to get focus simultaniously and they keep trying to get focus, thus an infinite loop of 2 controls alternating their focus.

    Setup:

    -webpage with 2 telerik comboboxes, both are required.
    -We need a dual screens.
    -windows 8 (might be reproducable in other windows versions)
    -browser, i've confirmed this in IE 11 end Chrome 42

     

    Steps to reproduce:
    select both combobxos, --> their validationmessage ust show up. Now set focus to the first combobox.
    Press the 'windows logo' key, then select the second combobox.
    The expected result here would be that the second combobox is the active element/combobox, but instead the 2 comboboxes keep alternating their focus.


  3. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 15 May 2015 Link to this post

    Hello Bart,

    I am afraid that the given information is not enough the fully understand the case. Would it be possible to send us a simple Dojo demo that demonstrates the issue? This will help us to review the issue locally and follow you up with more details.

    Regards,
    Georgi Krustev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top