Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8234919

FocusModel: focusPrevious violates specification if focusedIndex == -1

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx13
    • javafx

      Doc of focusPrevious:

      "If the current focus owner is the first row, or is -1 (representing that there is no current focus owner), calling this method will have no result."

      mapped to a test method:

          @Test
          public void focusPreviousFromNoFocus() {
              focusModel.focus(-1);
              assertEquals("sanity", -1, focusModel.getFocusedIndex());
              focusModel.focusPrevious();
              assertEquals(-1, focusModel.getFocusedIndex());
          }
          
      fails for all implementations - actually, already in the abstract base class (and overriding subs more or less just copied):

          public void focusPrevious() {
              if (getFocusedIndex() == -1) {
                  focus(0);
              } else if (getFocusedIndex() > 0) {
                  focus(getFocusedIndex() - 1);
              }
          }

      either implementation or specification must be changed to keep in sync

            aghaisas Ajit Ghaisas
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: