Pivot
  1. Pivot
  2. PIVOT-187

Container.requestFocus() lacks logic found in Component.transferFocus()

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1, 1.2
    • Fix Version/s: 1.3
    • Component/s: wtk
    • Labels:
      None

      Description

      Use case: create a CardPane with two cards and selectedIndex==1, where the second card is a TextInput. Now call cardPane.requestFocus(). You'd expect the TextInput to gain the focus, but it doesn't.

      The reason is that Container.requestFocus() asks its focus traversal policy for the next component, but it performs no checks on that next component to see if it's focusable or if it's a container that should be traversed. Such checks exist in Component.transferFocus(), which behaves as you'd expect. In the use case above, the index focus traversal policy returns the card at index 0, which is not focusable because it's not visible, and requestFocus() leaves it at that (having given nothing the focus).

      This leads to a confusing disparity between transferFocus() and requestFocus() – one works as you'd expect,and the other doesn't.

        Activity

        Todd Volkert created issue -
        Todd Volkert made changes -
        Field Original Value New Value
        Summary ContainerSkin.IndexFocusTraversalPolicy will return hidden and disabled components Container.requestFocus() lacks logic found in Component.transferFocus()
        Description Use case: create a CardPane with two cards and selectedIndex==2, where the second card is a TextInput. Now call cardPane.requestFocus(). You'd expect the TextInput to gain the focus, but it doesn't.

        The reason is that the index focus traversal policy used by the card pane (and most containers for that matter) will return you the first card because it's at index 0, but it fails to take into account the fact that the first card is invisible and thus not focusable. CardPane then calls requestFocus() on that invisible card, which ends up doing nothing.
        Use case: create a CardPane with two cards and selectedIndex==2, where the second card is a TextInput. Now call cardPane.requestFocus(). You'd expect the TextInput to gain the focus, but it doesn't.

        The reason is that Container.requestFocus() asks its focus traversal policy for the next component, but it performs no checks on that next component to see if it's focusable or if it's a container that should be traversed. Such checks exist in Component.transferFocus(), which behaves as you'd expect.

        This leads to a confusing disparity between transferFocus() and requestFocus() -- one works as you'd expect,and the other doesn't.
        Todd Volkert made changes -
        Description Use case: create a CardPane with two cards and selectedIndex==2, where the second card is a TextInput. Now call cardPane.requestFocus(). You'd expect the TextInput to gain the focus, but it doesn't.

        The reason is that Container.requestFocus() asks its focus traversal policy for the next component, but it performs no checks on that next component to see if it's focusable or if it's a container that should be traversed. Such checks exist in Component.transferFocus(), which behaves as you'd expect.

        This leads to a confusing disparity between transferFocus() and requestFocus() -- one works as you'd expect,and the other doesn't.
        Use case: create a CardPane with two cards and selectedIndex==1, where the second card is a TextInput. Now call cardPane.requestFocus(). You'd expect the TextInput to gain the focus, but it doesn't.

        The reason is that Container.requestFocus() asks its focus traversal policy for the next component, but it performs no checks on that next component to see if it's focusable or if it's a container that should be traversed. Such checks exist in Component.transferFocus(), which behaves as you'd expect. In the use case above, the index focus traversal policy returns the card at index 0, which is not focusable because it's not visible, and requestFocus() leaves it at that (having given nothing the focus).

        This leads to a confusing disparity between transferFocus() and requestFocus() -- one works as you'd expect,and the other doesn't.
        Todd Volkert made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]

          People

          • Assignee:
            Todd Volkert
            Reporter:
            Todd Volkert
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development