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

All Cells: cancelEvent must return correct editing location

XMLWordPrintable

      assuming we have an editing cell at editingIndex and a editCancel handler, the cancel event we receive in the handler must carry editingIndex as its cancelled edit location, something like

          control.edit(editingIndex);
          control.setOnEditCancel(e -> assertEquals(editingIndex, e.getIndex()));

      This invariant must hold always, independent of how the edit is cancelled:

      - cancel on control
      - cancel on cell
      - cell re-use
      - implicitly by modifying the items
      - tree/tableCell only: on collapse the parent

      currently, this invariant is broken differently for different cell types:

      - TreeCell (detected while fixing JDK-8265210) on cell re-use
      - ListCell (reported in JDK-8187226 and JDK-8165214) on cancel on control
      - Tree/TableCell (reported in JDK-8187229) on cancel on control

      that happens because the implementations either take the control's or the cell's editing location _at the time of sending_ the event:
          
           // ListCell, Tree/TableCell: use control's location
           editingLocation = control.getEditingLocation();
           fire(new XXEvent(...editingLocation...);

           // TreeCell
            editingLocation = this.getTreeItem();
            fire(new XXEvent(...editingLocation...)

      Both are wrong, leading to cell specific failures as noted in the related issues. The correct location is that _at the time of starting_ the cell edit.

      Locally, I have experimented with fixing TreeCell and it might be as simple as keeping track of the editing location in startEdit. If that really fixes the cancel (not fully tested yet), it should be applied to all cell types.

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

              Created:
              Updated:
              Resolved: