JDK-8090177 : [TreeTableView] selection is not cleared, when selected item is removed.
  • Type: Bug
  • Component: javafx
  • Sub-Component: controls
  • Affected Version: 8
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2012-12-22
  • Updated: 2020-06-24
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
Run the attached code:

import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Callback;

public class JavaFXApplication16 extends Application {

    TreeTableView<Data> treeTableView;

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

    @Override
    public void start(Stage stage) throws Exception {
        treeTableView = new TreeTableView<Data>();
        treeTableView.setRoot(new TreeItem<>(new Data("Root")));
        treeTableView.getRoot().getChildren().add(new TreeItem<Data>(new Data("item 1")));
        treeTableView.getRoot().getChildren().add(new TreeItem<Data>(new Data("item 2")));
        treeTableView.getRoot().getChildren().add(new TreeItem<Data>(new Data("item 3")));
        treeTableView.getRoot().setExpanded(true);

        treeTableView.getColumns().add(new TreeTableColumn<>("Data"));
        ((TreeTableColumn<Data, String>) treeTableView.getColumns().get(0)).setCellValueFactory(new Callback<TreeTableColumn.CellDataFeatures<Data,String>, ObservableValue<String>>() {
            @Override
            public ObservableValue<String> call(TreeTableColumn.CellDataFeatures<Data, String> p) {
                return p.getValue().getValue().property;
            }
        });

        Button b = new Button("remove");
        b.setOnAction(new EventHandler() {
            @Override
            public void handle(Event t) {
                treeTableView.getRoot().getChildren().remove(treeTableView.getRoot().getChildren().size() - 1);
            }
        });

        Button b1 = new Button("print selection");
        b1.setOnAction(new EventHandler() {
            @Override
            public void handle(Event t) {
                System.out.println("selected item : " + treeTableView.getSelectionModel().getSelectedItem());
            }
        });

        treeTableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() {
            @Override
            public void changed(ObservableValue ov, Object t, Object t1) {
                System.out.println("Changed selection to " + t1);
            }
        });

        VBox vb = new VBox();
        vb.getChildren().addAll(b, b1, treeTableView);

        Scene scene = new Scene(vb, 300, 300);
        stage.setScene(scene);
        stage.show();
    }

    class Data {

        public StringProperty property;

        public Data(String data) {
            property = new SimpleStringProperty(data);
        }

        @Override
        public String toString() {
            return property.get();
        }
    }
} 

Selected the last item (item 3) and click button remove.
Note, that there is no any output.
Click button "print selection" and you will see, that removed item is still selected.

I expect, that selection should be cleared.

Affected tests:
ControlsAutomatedTestSuite/javafx/scene/control/test/treetable/TreeTableAsOldTreeTest/removeTest