Skip to content

Grid tooltip generator throws "Cannot destructure property 'gridtooltips' of 'item' as it is undefined" (regression from #9697) #10247

Closed

Description

@letrthang

Description

Grid.addTooltipElementToTooltipSlot assigns the grid's <vaadin-tooltip> this generator:

this.generator = ({ item, column }) => {
    const { gridtooltips } = item;
    if (gridtooltips) {
        return (column ? gridtooltips[column._flowId] : null) ?? gridtooltips.row;
    }
}

#9697 ("refactor: improve readability of grid generator functions") removed the item && guard. 25.2.x had it, and it was originally added in #3760:

this.generator = ({item, column}) => { return (item && item.gridtooltips && column) ? item.gridtooltips[column._flowId] ?? item.gridtooltips['row'] : ''; }

The generator is called when there is no item, in two cases:

  1. <vaadin-tooltip>'s updated() calls __updateContent() → generator(this.context) as soon as generator is assigned. context defaults to {}, so every grid with a tooltip generator throws once when the tooltip element is attached. That happens on first render, or when a hidden grid becomes visible.
  2. vaadin-grid also calls _showTooltip for header / footer cells (__onCellMouseEnter is added to every cell). getEventContext has no item for those sections, so hovering any column header throws.

Each throw is an unhandled promise rejection (__updateContent is async):

Uncaught (in promise) TypeError: Cannot destructure property 'gridtooltips' of 'item' as it is undefined.

Main still has the unguarded line.

Expected outcome

No error. When the context has no item, the generator returns no tooltip text, as 25.2.x did.

Minimal reproducible example

@Route("")
public class GridTooltipView extends VerticalLayout {
    public GridTooltipView() {
        Grid<String> grid = new Grid<>();
        grid.addColumn(s -> s).setHeader("Value")
                .setTooltipGenerator(s -> "tooltip for " + s);
        grid.setItems("a", "b", "c");
        grid.setVisible(false);

        add(new Button("Show grid", e -> grid.setVisible(true)), grid);
    }
}

Steps to reproduce

  1. Open the view and the browser console.
  2. Click Show grid. One Cannot destructure property 'gridtooltips' of 'item' as it is undefined error appears. Without the setVisible(false), it appears on initial render instead.
  3. Hover the Value column header. The same error appears again on each hover.
  4. Hover a body cell. The tooltip still works.

Suggested fix: const { gridtooltips } = item ?? {};, or restore the item && guard.

Environment

  • Vaadin 25.3.0: flow-server 25.3.0, vaadin-grid-flow 25.3.0, @vaadin/grid / @vaadin/tooltip 25.3.0
  • Spring Boot 4.1.1, Java 25 (Corretto 25.0.4.1)
  • Production mode, macOS
  • Workaround we use: wrap vaadin-tooltip's generator setter so a grid-slotted tooltip returns '' when context.item is missing

Browsers

Chrome

Activity

  1. web-padawan commented on Sep 26, 2026

    @web-padawan
    Member

    Thanks for the issue. Sorry for the inconvenience, missed this during the review. Will work on a fix.

  2. web-padawan commented on Sep 26, 2026

    @web-padawan
    Member

    @claude fix generator and add a test

  3. claude commented on Sep 26, 2026

    @claude

    Claude finished @web-padawan's task in 3m 43s —— View job • claude/issue-10247-20260926-1202 • Create PR ➔


    Done ✅

    Fixed the regression from #9697 and added test coverage.

    Tasks

    • Read issue and locate the generator
    • Fix the generator to guard against missing item
    • Add a test
    • Build & verify (module + test sources compile, spotless:apply clean)
    • Commit and push

    What changed

    • Grid.java — restored the missing-item guard in the slotted <vaadin-tooltip> generator:
      const { gridtooltips } = item ?? {};
      The generator is invoked with no item twice: once with the default empty context ({}) when the tooltip element attaches (first render / hidden-grid-becomes-visible), and again for header/footer cells on hover. Both used to throw Cannot destructure property 'gridtooltips' of 'item' as it is undefined.
    • GridTooltipIT.java
      • Added hoverOverColumnHeader_shouldNotProduceErrors — hovers a column header (no item in the event context) and asserts no browser errors. This fails without the fix.
      • Tightened tooltipGenerator_shouldNotProduceErrors to use the strict checkLogsForErrors(). It previously suppressed Cannot read properties of undefined, which was hiding exactly this class of error.

    Note

    I compiled the modules and formatted the code, but did not run the browser-based integration tests here (they need a running Jetty server + browser). Worth a CI run to confirm the two GridTooltipIT cases pass.

    • Branch: claude/issue-10247-20260926-1202

  4. vaadin-bot commented on Sep 29, 2026

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with Vaadin 25.4.0-alpha1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions