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

FocusModel: focusPrevious violates specification if focusedIndex == -1

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: openjfx13
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:

      Description

      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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated: