Skip to content

Conversation

web-padawan
Copy link
Member

Description

Updated dialog to always set overflow attribute even if no header / footer renderer is set.

This fixes base styles to make it work e.g. the following case:

<vaadin-dialog opened>
  <div id="content" style="max-width: 300px"></div>
</vaadin-dialog>

<script type="module">
  const div = document.querySelector('#content');
  div.textContent = Array(100).join('Lorem ipsum dolor sit amet');
</script>

Type of change

  • Refactor

Note

We could probably debounce calls to __updateOverflow() but that can be done separately.

@@ -68,14 +68,21 @@ export const DialogOverlayMixin = (superClass) =>

// Update overflow attribute on resize
this.__resizeObserver = new ResizeObserver(() => {
this.__updateOverflow();
requestAnimationFrame(() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because otherwise I was getting the following error in the new tests:

Uncaught Error: ResizeObserver loop completed with undelivered notifications.

Using requestAnimationFrame() generally makes sense here (we use setTimeout in ResizeMixin).

overlay = dialog.$.overlay;
});

describe('slotted content', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new test suite that covers changes in the PR.

@web-padawan web-padawan force-pushed the refactor/dialog-content-overflow branch from fe1c823 to 5586810 Compare August 5, 2025 17:21
Copy link

sonarqubecloud bot commented Aug 5, 2025

@@ -69,26 +69,22 @@
height: auto;
}

@media (min-height: 320px) {
Copy link
Member Author

@web-padawan web-padawan Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we had this breakpoint. It seems confusing and overflow attribute would not be set on resizer container scroll, so I changed to align with base styles to only make content part scrollable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it’s a bit confusing. The idea is that on a very narrow dialog the header and footer would also scroll, to give more space for the content area. But a container query would be the right solution to accomplish that, not a media query, as you could have a narrow dialog even without a narrow viewport.

I think this type of optimization might be better left for application code.

@@ -69,26 +69,22 @@
height: auto;
}

@media (min-height: 320px) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it’s a bit confusing. The idea is that on a very narrow dialog the header and footer would also scroll, to give more space for the content area. But a container query would be the right solution to accomplish that, not a media query, as you could have a narrow dialog even without a narrow viewport.

I think this type of optimization might be better left for application code.

@web-padawan web-padawan merged commit aad0c3e into main Aug 6, 2025
9 checks passed
@web-padawan web-padawan deleted the refactor/dialog-content-overflow branch August 6, 2025 08:23
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.

3 participants