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

onclientblur event is not fired if tab key is pressed

1 Answer 595 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
Bharathwajan Venkatanarayanan asked on 12 Nov 2009, 06:39 AM
Hi,

we have attached a javascript function in Onclientblur event of a Radcombobox.
if there is new value selected in the combo, the javascript function will run and it will increase the progressbar and set the focus to display button.
this is working fine if i change the value in the combo and click any where on the screen.
but if i press tab from the combo ,the focus is going away from the display button.
when i debug my javascript,i have been redircted to a telerik dll in the following section

else

 

{if(d===Telerik.Web.UI.Keys.Tab){if(this.get_dropDownVisible()){this._hideDropDown(f)

 

}

this._raiseClientBlur(f);

 

this

 

._selectItemOnBlur(f);

 

this

 

._focused=false;

 

return


if i select some value in combo and click out side i am getting in to the following code in telerik dll

if

 

(this._focused){this._raiseClientBlur(c);

 

this

 

._selectItemOnBlur(c);

 

this

 

._focused=false;
the second one works fine and the focus is on display button.if i wont click out side and just press the tab the focus is going away from the display button.

please let me know what went wrong and what i should do to set the focus on the button if i press tab from radcombobox.
thanks,
Bharathwajan

 

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 17 Nov 2009, 02:21 PM
Hello Bharathwajan Venkatanarayanan,

The code which executes in the Blur event handler when the Tab key is pressed is actually processed on the keydown event. In this moment the focus is not yet moved to the next element (which is the browser behavior). So, if you set the focus to the button, after the event handler executes the browser moves the focus to the element next to the button in the tab order.

Please try resolving the issue with either of the approaches:
  • Verify whether the Tab key has been pressed in the Blur event handler and prevent the default browser action in this case:
    var domEvent = eventArgs.get_domEvent();
    var keyCode = domEvent.keyCode || domEvent.which;
     
    if (keyCode == 9)
        domEvent.preventDefault();
  • Call the code focusing the button with a timeout:
    setTimeout(function() { /* focusing code */ }, 0);

Sincerely yours,
Simon
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
Bharathwajan Venkatanarayanan
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or