Skip to content

Commit c57aaea

Browse files
authored
fix: add better checks to grid tooltip generator function (#3760)
1 parent ff0c952 commit c57aaea

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

  • vaadin-grid-flow-parent
    • vaadin-grid-flow-integration-tests/src/test/java/com/vaadin/flow/component/grid/it
    • vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid

‎vaadin-grid-flow-parent/vaadin-grid-flow-integration-tests/src/test/java/com/vaadin/flow/component/grid/it/GridTooltipIT.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public void init() {
3232
open();
3333
}
3434

35+
@Test
36+
public void tooltipGenerator_shouldNotProduceErrors() {
37+
checkLogsForErrors(
38+
msg -> !msg.contains("Cannot read properties of undefined"));
39+
}
40+
3541
@Test
3642
public void hoverOverTooltipColumnCell_showTooltip() {
3743
var grid = $(GridElement.class).first();

‎vaadin-grid-flow-parent/vaadin-grid-flow/src/main/java/com/vaadin/flow/component/grid/Grid.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ public Column<T> setTooltipGenerator(
10571057
// Assigns a generator that returns a column-specfic
10581058
// tooltip text from the item
10591059
tooltipElement.executeJs(
1060-
"this.textGenerator = ({item, column}) => item.gridtooltips[column._flowId]");
1060+
"this.textGenerator = ({item, column}) => { return (item && item.gridtooltips && column) ? item.gridtooltips[column._flowId] : ''; }");
10611061
});
10621062
getGrid().getElement().appendChild(tooltipElement);
10631063
}

0 commit comments

Comments
 (0)