Skip to content

Selecting an unselected row dispatches two selection events #32

@RhonanMS

Description

@RhonanMS

I am using a SelectGrid with a TableSelectionModel using the selection mode TableSelectionMode.SHIFT.

When selecting a previously unselected row without holding the Ctrl key, the underlying CtrlClickSelectionHandler calls SelectionModel<JsonObject>.deselectAll(). This triggers an event with an empty selection, almost immediately following by an event with the newly selected row.

Example:

SelectGrid<T> grid2 = new SelectGrid<>();
TableSelectionModel<T> tableSelectionModel = new TableSelectionModel<>();
tableSelectionModel.setMode(TableSelectionMode.SHIFT);
grid2.setSelectionModel(tableSelectionModel);
grid2.addSelectionListener(event -> {
	LOGGER.debug(String.format("%d entries in selection", 
		event.getAllSelectedItems().size()));
});

When selecting a row as described above, the logger returns the following:

[DEBUG] 0 entries in selection 
[DEBUG] 1 entries in selection 

I would have expected only one event containing the new selection instead of two, one of which contains an empty selection. Is it possible to allow for this behaviour?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions