Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public void focusOnCell(T item) {
*/
public void focusOnCell(T item, Column<T> column) {
int index = getIndexForItem(item);
if (index > 0) {
int colIndex = (column != null) ? getColumns().indexOf(column) : 0;
if (index >= 0) {
int colIndex = (column != null) ? getColumns().indexOf(column) : 1;
// delay the call of focus on cell if it's used on the same round trip (grid creation + focusCell)
this.getElement().executeJs("setTimeout(function() { $0.focusOnCell($1, $2) });", getElement(), index, colIndex);
}
Expand Down Expand Up @@ -241,4 +241,4 @@ public void removeThemeVariants(SelectionGridVariant... variants) {
getThemeNames().removeAll(Stream.of(variants)
.map(SelectionGridVariant::getVariantName).collect(Collectors.toList()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
customElements.whenDefined("vaadin-selection-grid").then(() => {
const Grid = customElements.get("vaadin-selection-grid");
if (Grid) {
const oldOnContextMenuHandler = Grid.prototype._onContextMenu;
Grid.prototype._onContextMenu = function _onContextMenu(e) {

const tr = e.composedPath().find((p) => p.nodeName === "TR");
if (tr && typeof tr.index != 'undefined') {
const item = tr._item;
const index = tr.index;
if (this.selectedItems && this.selectedItems.some((i) => i.key === item.key)) {
// in case current row selected, do nothing, else
} else {
this._selectionGridSelectRow(e);
}
}

const boundOnConextMenuHandler = oldOnContextMenuHandler.bind(this);
boundOnConextMenuHandler(e);
}

const oldClickHandler = Grid.prototype._onClick;
Grid.prototype._onClick = function _click(e) {
const boundOldClickHandler = oldClickHandler.bind(this);
Expand Down