JDK-8254907 : TableView - accessible text in cell is not cleared when content becomes empty
  • Type: Bug
  • Component: javafx
  • Sub-Component: accessibility
  • Affected Version: 8u192
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2020-10-15
  • Updated: 2020-10-16
  • Resolved: 2020-10-16
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 10, jdk 1.8u192

A DESCRIPTION OF THE PROBLEM :
the accessible text is updated only if the new value (as String) is not null and not empty.

TreeTableView has the same problem.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute attached example, start Windows screen reader.
sort by column "Last Name"



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Screen reader says nothing for Last name, first row
ACTUAL -
Screen reader "B" nothing for Last name, first row

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class TableViewExample extends Application {
    private final TableView<Person> table = new TableView<>();
    private final ObservableList<Person> data =
            FXCollections.observableArrayList(new Person("A", "B"), new Person("B", null));
 
    public static void main(String[] args) {
        launch(args);
    }
 
    @Override
    public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        stage.setWidth(450);
        stage.setHeight(550);
 
 
        TableColumn firstNameCol = new TableColumn("First Name");
        firstNameCol.setMinWidth(100);
        firstNameCol.setCellValueFactory(
                new PropertyValueFactory<>("firstName"));
 
        TableColumn lastNameCol = new TableColumn("Last Name");
        lastNameCol.setMinWidth(100);
        lastNameCol.setCellValueFactory(
                new PropertyValueFactory<>("lastName"));
 
        table.setItems(data);
        table.getColumns().addAll(firstNameCol, lastNameCol);
 
 
        final VBox vbox = new VBox();
        vbox.setSpacing(5);
        vbox.setPadding(new Insets(10, 0, 0, 10));
        vbox.getChildren().addAll(table);
 
        ((Group) scene.getRoot()).getChildren().addAll(vbox);
 
        stage.setScene(scene);
        stage.show();
    }
 
    public static class Person {
 
        private final SimpleStringProperty firstName;
        private final SimpleStringProperty lastName;
 
        private Person(String fName, String lName) {
            this.firstName = new SimpleStringProperty(fName);
            this.lastName = new SimpleStringProperty(lName);
        }
 
        public String getFirstName() {
            return firstName.get();
        }
 
        public void setFirstName(String fName) {
            firstName.set(fName);
        }
 
        public String getLastName() {
            return lastName.get();
        }
 
        public void setLastName(String fName) {
            lastName.set(fName);
        }
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
can be workarounded by setting a custom cell factory which sets a custom skin to each created cell.
those skin needs to override the queryAccessibleAttribute method to return the correct value for the text attribute.

if one uses context menus there needs to be another workaround for https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8236840 which can only be done by using reflection. (remove the event handler when skin is disposed)

FREQUENCY : always



Comments
This might be a duplicate of JDK-8203345.
15-10-2020