Skip to content

Dropdown column value becomes empty after pressing Tab (double closeEditor call reads a closed widget) #1802

Description

@hastalavista911

Package / version: jspreadsheet-ce 5.0.4 (latest on npm at time of writing)

Steps to reproduce

  1. Create a worksheet with a column of type: 'dropdown' (see minimal reproduction below).
  2. Double-click the cell to open the dropdown editor.
  3. Pick an option (or leave the currently highlighted/default option as-is).
  4. Press Tab.

Minimal reproduction:

jspreadsheet(document.getElementById('spreadsheet'), {
  worksheets: [{
    data: [[1]],
    columns: [
      { type: 'dropdown', title: 'Status', source: [
        { id: 1, name: 'Open' },
        { id: 2, name: 'Closed' }
      ] }
    ]
  }]
});

Expected behavior

The selected value is committed to the cell, and focus moves to the next cell — standard Tab behavior.

Actual behavior

The cell value becomes empty.

Root cause (from reading the minified source, jspreadsheet.min.js)

  • On Tab while a dropdown editor is open, keyDownControls does not call closeEditor directly. Instead it calls current.edition[0].children[0].blur().
  • That blur() triggers the jSuites.dropdown widget's own close handling, which invokes the onclose callback registered in openEditor, roughly: onclose: function () { closeEditor.call(n, e, true); }.
  • closeEditor(e, true) (commit=true) for a dropdown column reads the value with r = e.children[0].dropdown.close(true); — calling .close(true) on the widget a second time, while it's already mid-close from the blur that triggered this whole chain.
  • This second .close(true) call reads from a widget instance whose internal state has already been torn down/reset by the first close, so it returns an empty value, which then gets written back to the cell.

Call chain summary:

blur()
  -> jSuites.dropdown widget's own close handling
    -> onclose callback -> closeEditor(e, true)
      -> e.children[0].dropdown.close(true)   // 2nd close call, widget already closing
        -> returns empty value -> written to cell

Related open issues (same symptom, no fix landed yet)

Workaround

Click another cell instead of pressing Tab after selecting a dropdown option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions