ICEfaces
  1. ICEfaces
  2. ICE-5892

Calling requestFocus() on a field doesn't always move focus to the field in IE

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.8.2-EE-GA_P01
    • Fix Version/s: None
    • Component/s: Bridge
    • Labels:
      None
    • Environment:
      Linux, Glassfish 2.2.1

      Description

      Calling requestFocus() on a field does not always move the focus to the requested field when running in Internet Explorer (IE). This issue occurs occasionally when rendering a page and attempting to focus on the first field on that page. It occurs quite frequently when calling focus a HtmlInputText field on a PanelTab in a PanelTabSet when the PanelTab is set as the active tab in the same code execution path as the render that calls the requestFocus on the HtmlInputText that is on the newly displayed PanelTab. In this case IE failed to correctly set the focus about 90% of the time.

        Activity

        Hide
        Ed Hillmann added a comment - - edited

        After examining the Icefaces focus javascript (icefaces/bridge/src/focus.js) there is code in there to delay for 100ms due to an IE focus issue (Icefaces bug ICE-1247). We have found that this delay in the javascript is not always sufficient to allow IE time to render components prior to attempting to focus. If the delay is increased it appears to focus correctly about 60% of the time at 250ms and always performs the focus correctly at about the 500ms mark. However, at this point there becomes a noticeable delay prior to the focus occurring when the delay is set to 500ms. We have modified the javascript to handle focus issues in IE without using a delay. The solution applied is to add a second focus call on the element to be focused if the activeElement is not the same as the focus element after the first focus call. A test case was executed that performed a focus to a field on a non-displayed PanelTab (setting the active tab of the PanelTabSet prior to the requestFocus call), check the focus was set, selected another PanelTab and repeated this 50 times. Without the changes this failed consistently in IE and with the changes passed 100% (i.e. all 50 focus calls resulted in the correct field receiving focus). This test was also performed against FireFox to ensure there was no change in FF behaviour and it passed 100% as well.

        I have attached the changes to focus.js as a patch to this issue.

        Show
        Ed Hillmann added a comment - - edited After examining the Icefaces focus javascript (icefaces/bridge/src/focus.js) there is code in there to delay for 100ms due to an IE focus issue (Icefaces bug ICE-1247 ). We have found that this delay in the javascript is not always sufficient to allow IE time to render components prior to attempting to focus. If the delay is increased it appears to focus correctly about 60% of the time at 250ms and always performs the focus correctly at about the 500ms mark. However, at this point there becomes a noticeable delay prior to the focus occurring when the delay is set to 500ms. We have modified the javascript to handle focus issues in IE without using a delay. The solution applied is to add a second focus call on the element to be focused if the activeElement is not the same as the focus element after the first focus call. A test case was executed that performed a focus to a field on a non-displayed PanelTab (setting the active tab of the PanelTabSet prior to the requestFocus call), check the focus was set, selected another PanelTab and repeated this 50 times. Without the changes this failed consistently in IE and with the changes passed 100% (i.e. all 50 focus calls resulted in the correct field receiving focus). This test was also performed against FireFox to ensure there was no change in FF behaviour and it passed 100% as well. I have attached the changes to focus.js as a patch to this issue.
        Hide
        Ed Hillmann added a comment -

        I should add that we're using IE 8.

        Show
        Ed Hillmann added a comment - I should add that we're using IE 8.

          People

          • Assignee:
            Unassigned
            Reporter:
            Ed Hillmann
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: