Skip to content

fix: Make SpreadsheetOverlay native popover (#9241)#9270

Closed
TatuLund wants to merge 1 commit into
mainfrom
fix9240
Closed

fix: Make SpreadsheetOverlay native popover (#9241)#9270
TatuLund wants to merge 1 commit into
mainfrom
fix9240

Conversation

@TatuLund

Copy link
Copy Markdown
Contributor

Fixes #9240

Note1: Spreadsheet tabs initial alignment is wrong if the first tab is not the selected one when Spreadsheet is placed on Dialog. This is not regression from this PR, but a different bug that needs to be addressed separately.

Note2: When Spreadsheet is in Dialog, inserting comment does not work. This is not regression from this PR, as inserting comment after this PR still works, when Spreadsheet is not in Dialog. This is different bug that needs to be address separately.

  • Actually these bugs happen also with Vaadin 24.10, so they are not regressions from Dialog's native popover refactor.

Fixes #9240 

Note1: Spreadsheet tabs initial alignment is wrong if the first tab is
not the selected one when Spreadsheet is placed on Dialog. This is not
regression from this PR, but a different bug that needs to be addressed
separately.

Note2: When Spreadsheet is in Dialog, inserting comment does not work.
This is not regression from this PR, as inserting comment after this PR
still works, when Spreadsheet is not in Dialog. This is different bug
that needs to be address separately.

- Actually these bugs happen also with Vaadin 24.10, so they are not
regressions from Dialog's native popover refactor.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
32.1% Duplication on New Code (required ≤ 10%)

See analysis details on SonarQube Cloud

@DiegoCardoso

Copy link
Copy Markdown
Contributor

There's one issue I found and it relates with the modal dialogs. Spreadsheet creates a <div id="spreadsheet-overlays> in the <body> and place all the overlay inside this element (similar to the overlays in Vaadin before the V25 refactor). So, when Spreadsheet is placed inside a modal Dialog, the options are not reachable. That explains the comment in Note2 (I haven't tested in V24, but it could be the same issue there).

Perhaps, with the usage of native popover, there's no need to have the <div> mentioned above inside the <body> and move it to the <vaadin-spreadsheet> instead.

Modal Dialog (doesn't work)

ss-dialog-popover.mp4

Modaless Dialog (works)

ss-modeless-dialog-popover.mp4

There are also a lot of errors logged in the client console when the Dialog opens:
image

It seems to be unrelated to these changes, though, as I verified it in main too.

@TatuLund

Copy link
Copy Markdown
Contributor Author

It seems to be unrelated to these changes, though, as I verified it in main too.

@DiegoCardoso Exactly. Thus I would prefer to do separate PR about that, which could be more clearly backported to Vaadin 24 as well. The native popover implementation is Vaadin 25 specific.

@DiegoCardoso

Copy link
Copy Markdown
Contributor

I've created PR #9303 based on this (still in draft). The main change is to render the overlays as children of the Spreadsheet instances instead of appending them to , which fixes the issue with modal dialogs. This also resolves the issue mentioned above regarding adding comments to cells when a Spreadsheet is inside a dialog.

@yuriy-fix

Copy link
Copy Markdown
Contributor

Closing in favor of #9303

@yuriy-fix yuriy-fix closed this Jun 9, 2026
DiegoCardoso added a commit that referenced this pull request Jun 11, 2026
…CP: 25.2) (#9495)

This PR cherry-picks changes from the original PR #9303 to branch 25.2.
---
#### Original PR description
> The spreadsheet attaches a `<div id="spreadsheet-overlays">` to host
its overlay widgets (context menu, tooltips, comment overlays, popup
buttons). It has historically lived in `<body>` to escape clipping by
ancestor `overflow`/`transform` rules and as a singleton shared by all
spreadsheet instances on the page. Switching the overlays to native
popover changes the picture: every overlay enters the top layer
regardless of DOM position, so neither the body-attachment nor the
singleton are load-bearing anymore.
> 
> This PR includes the native popover changes proposed in #9270 and adds
the structural changes that the popover approach enables:
> 
> - the container moves into the `<vaadin-spreadsheet>` light DOM,
projected into the shadow root via a new `overlays` slot, with one
container per instance;
> - the reference is threaded from JS into the GWT widget chain instead
of being looked up by id;
> - `SpreadsheetConnector` — not `ApplicationConnection` — now owns the
`SpreadsheetContextMenu`.
> 
> Tooltips and the cell-comment overlay are created in `SheetWidget`'s
constructor (before the host is known), so the container is wired in via
a setter rather than a constructor argument.
> 
> A side benefit: spreadsheet overlays inside a modal `Dialog` are
interactive again. The modal sets `body { pointer-events: none }` to
disable everything outside the dialog overlay; with the container now
inside the dialog's slotted content, the overlays inherit
`pointer-events: auto` from the dialog's overlay part instead of
`pointer-events: none` from `<body>`.
> 
> Intended to replace #9270.
> 
> Related to #9270
> 
> ---
> 
> 🤖 Generated with Claude Code

Co-authored-by: Diego Cardoso <diego@vaadin.com>
Co-authored-by: Tatu Lund <tatu@vaadin.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
DiegoCardoso added a commit that referenced this pull request Jun 12, 2026
…CP: 25.1) (#9496)

This PR cherry-picks changes from the original PR #9303 to branch 25.1.
---
#### Original PR description
> The spreadsheet attaches a `<div id="spreadsheet-overlays">` to host
its overlay widgets (context menu, tooltips, comment overlays, popup
buttons). It has historically lived in `<body>` to escape clipping by
ancestor `overflow`/`transform` rules and as a singleton shared by all
spreadsheet instances on the page. Switching the overlays to native
popover changes the picture: every overlay enters the top layer
regardless of DOM position, so neither the body-attachment nor the
singleton are load-bearing anymore.
> 
> This PR includes the native popover changes proposed in #9270 and adds
the structural changes that the popover approach enables:
> 
> - the container moves into the `<vaadin-spreadsheet>` light DOM,
projected into the shadow root via a new `overlays` slot, with one
container per instance;
> - the reference is threaded from JS into the GWT widget chain instead
of being looked up by id;
> - `SpreadsheetConnector` — not `ApplicationConnection` — now owns the
`SpreadsheetContextMenu`.
> 
> Tooltips and the cell-comment overlay are created in `SheetWidget`'s
constructor (before the host is known), so the container is wired in via
a setter rather than a constructor argument.
> 
> A side benefit: spreadsheet overlays inside a modal `Dialog` are
interactive again. The modal sets `body { pointer-events: none }` to
disable everything outside the dialog overlay; with the container now
inside the dialog's slotted content, the overlays inherit
`pointer-events: auto` from the dialog's overlay part instead of
`pointer-events: none` from `<body>`.
> 
> Intended to replace #9270.
> 
> Related to #9270
> 
> ---
> 
> 🤖 Generated with Claude Code

Co-authored-by: Diego Cardoso <diego@vaadin.com>
Co-authored-by: Tatu Lund <tatu@vaadin.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
DiegoCardoso added a commit that referenced this pull request Jun 12, 2026
…CP: 25.0) (#9497)

This PR cherry-picks changes from the original PR #9303 to branch 25.0.
---
#### Original PR description
> The spreadsheet attaches a `<div id="spreadsheet-overlays">` to host
its overlay widgets (context menu, tooltips, comment overlays, popup
buttons). It has historically lived in `<body>` to escape clipping by
ancestor `overflow`/`transform` rules and as a singleton shared by all
spreadsheet instances on the page. Switching the overlays to native
popover changes the picture: every overlay enters the top layer
regardless of DOM position, so neither the body-attachment nor the
singleton are load-bearing anymore.
> 
> This PR includes the native popover changes proposed in #9270 and adds
the structural changes that the popover approach enables:
> 
> - the container moves into the `<vaadin-spreadsheet>` light DOM,
projected into the shadow root via a new `overlays` slot, with one
container per instance;
> - the reference is threaded from JS into the GWT widget chain instead
of being looked up by id;
> - `SpreadsheetConnector` — not `ApplicationConnection` — now owns the
`SpreadsheetContextMenu`.
> 
> Tooltips and the cell-comment overlay are created in `SheetWidget`'s
constructor (before the host is known), so the container is wired in via
a setter rather than a constructor argument.
> 
> A side benefit: spreadsheet overlays inside a modal `Dialog` are
interactive again. The modal sets `body { pointer-events: none }` to
disable everything outside the dialog overlay; with the container now
inside the dialog's slotted content, the overlays inherit
`pointer-events: auto` from the dialog's overlay part instead of
`pointer-events: none` from `<body>`.
> 
> Intended to replace #9270.
> 
> Related to #9270
> 
> ---
> 
> 🤖 Generated with Claude Code

Co-authored-by: Diego Cardoso <diego@vaadin.com>
Co-authored-by: Tatu Lund <tatu@vaadin.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spreadsheet overlays do not work when Spreadsheet is in Dialog.

3 participants