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

ListView et al: start edit with SPACE must not delete editor content

XMLWordPrintable

      when starting edit with space, editor content is replaced by " " (= space), happens only if the cell has been in editing state before

      Seen for ListView, Tree/TableView (not TreeView which doesn't seem to have a binding of space to activate?).

      Might be similar as the second part of JDK-8089020 (though in that issue it seems to have happened always).

      Reproducible (haven't checked others): fx11, fx17, current fx18dev

      To reproduce, run the example
      - start/terminate edit on a cell (doesn't matter by which means)
      - start edit on the same cell by space
      - expected: editor contains the item at the index
      - actual: editor contains a single (unselected) space

      Example code:

      public class ListTextFieldStartEdit extends Application {
          
          int count;
          private Parent createContent() {
              ObservableList<String> items = FXCollections.observableArrayList(
                      Stream.generate(() -> "item" + count++)
                      .limit(50)
                      .collect(Collectors.toList()));
              ListView<String> list = new ListView<>(items);
              list.setEditable(true);
              list.setCellFactory(TextFieldListCell.forListView());
              
              VBox content = new VBox(10, list);
              return content;
          }

          @Override
          public void start(Stage stage) throws Exception {
              stage.setScene(new Scene(createContent()));
              stage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }

      }

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

              Created:
              Updated: