Skip to content

fix(dialog): improved handling of scrollable content - #9236

Open
crisbeto wants to merge 1 commit into
angular:mainfrom
crisbeto:dialog-scrollable-proper
Open

fix(dialog): improved handling of scrollable content#9236
crisbeto wants to merge 1 commit into
angular:mainfrom
crisbeto:dialog-scrollable-proper

Conversation

@crisbeto

Copy link
Copy Markdown
Member
  • Improves the handling of scrollable content inside the mat-dialog-content by using flexbox, rather than a hardcoded max-height, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars.
  • Uses flexbox to ensure that the dialog content elements are always at the appropriate size.

Fixes#2481.
Fixes#3239.
Fixes#6584.
Fixes#8493.

@googlebotgooglebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 4, 2018
@crisbeto
crisbetoforce-pushed the dialog-scrollable-proper branch from 8ee04db to 214f719CompareJanuary 4, 2018 19:43
this._savePreviouslyFocusedElement();
return this._portalOutlet.attachComponentPortal(portal);

const componentRef = this._portalOutlet.attachComponentPortal(portal);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add a comment here that explains why this extra class is added?

@@ -1 +1,3 @@
<ng-template cdkPortalOutlet></ng-template>
<div class="mat-dialog-component-host">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this class meant to be both in the template and added manually?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Yeah, we need to add it through both to cover both template and dialog portals. The class is used to propagate the max-height down correctly since we've got a lot of nested divs.


/** Max-height of the dialog. If a number is provided, pixel units are assumed. */
maxHeight?: number | string;
maxHeight?: number | string = '80vh';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Was this 65vh before? If so, we probably would need to keep the same max-height until a major version change

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

It wasn't, it was the scrollable content that was 65vh, this applies the height to the overlay pane itself.

Comment threadsrc/lib/dialog/dialog.scss Outdated
justify-content: center;
width: 100%;
flex-shrink: 0;
order: 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wouldn't specifying the order take away the ability to put custom content in between the regions?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I suppose that it would, but the assumption is that if they're using the content element, they're putting all their content into it. I'm fine with removing it though, we haven't had it until now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the only reason would be to let people put the dialog directives in any order, I'd rather omit it to give people control in case they need to do something special

@crisbeto
crisbetoforce-pushed the dialog-scrollable-proper branch from 214f719 to fb4dbf0CompareJanuary 12, 2018 18:22
@crisbeto

Copy link
Copy Markdown
MemberAuthor

Addressed the feedback @jelbourn.

jelbourn
jelbourn previously approved these changes Jan 12, 2018

@jelbournjelbourn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jelbournjelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release and removed pr: needs review labels Jan 12, 2018
@crisbeto
crisbetoforce-pushed the dialog-scrollable-proper branch from fb4dbf0 to 67ab3e9CompareJanuary 24, 2018 17:09
@crisbeto
crisbetoforce-pushed the dialog-scrollable-proper branch from 67ab3e9 to 2a31c21CompareMarch 2, 2018 20:58
@dinamix1

Copy link
Copy Markdown

Looking forward to this merge!

@crisbeto
crisbetoforce-pushed the dialog-scrollable-proper branch from 2a31c21 to 2c65285CompareMarch 30, 2018 14:53
@crisbeto
crisbetoforce-pushed the dialog-scrollable-proper branch from 2c65285 to 3c45beeCompareApril 18, 2018 19:06
@pharv

Copy link
Copy Markdown

Great work on this PR! I am really looking forward to this enhancement as well. It looks like the only reason it hasn't been merged in yet is because the Travis CI build failed due to server issues. Can someone please re-run the build? Thanks!

@andrewseguinandrewseguin added the presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged label Apr 26, 2018
@Devvox93

Copy link
Copy Markdown

What are the presubmit failures that are keeping this from being merged?
I, too, am having the same scrolling issues with the material dialogs.

@ngbot

ngbotBot commented Jul 11, 2018

Copy link
Copy Markdown

Hi @crisbeto! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@tammysock

Copy link
Copy Markdown

This fix will be very helpful. Any updates on the PR?

@swftvsn

Copy link
Copy Markdown
Contributor

Hi, I would really appreciate this fix too, we've been waiting for a year now for this to land (we're eager to take out our own hacks to overcome some issues that this would fix..)

So, any news about this @crisbeto@jelbourn ?

* Improves the handling of scrollable content inside the `mat-dialog-content` by using flexbox, rather than a hardcoded `max-height`, to define the content height. This resolves various issues where the dialog would go out of the screen at certain screen sizes or have multiple scrollbars.
* Uses flexbox to ensure that the dialog content elements are always at the appropriate size.
Fixesangular#2481.
Fixesangular#3239.
Fixesangular#6584.
Fixesangular#8493.
@crisbeto
crisbetoforce-pushed the dialog-scrollable-proper branch from cc3ba6f to dccfb41CompareMarch 30, 2019 13:51
@mmalerbammalerba added aaa and removed aaa labels Apr 25, 2019
@MaximoB

Copy link
Copy Markdown

This PR would fix major problems I'm having using MatDialog, any updates?

@andrewseguinandrewseguin added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label May 30, 2019
@akvaliya

Copy link
Copy Markdown

What is the status of this PR? When will it be completed.

@charsleysa

Copy link
Copy Markdown

@jelbourn is this still blocked?

@jelbourn

Copy link
Copy Markdown
Contributor

Yes- we haven't work on this since the last update. At this point, we'll probably see if we can address this as part of our work on integrating MDC-web into the components.

@AlexElin

Copy link
Copy Markdown
Contributor

@jelbourn have you had a chance to find out whether integrating MDC-web into the components will solve the problems that this PR intended to solve?

@jelbourn

Copy link
Copy Markdown
Contributor

@crisbeto is this something you've looked at for the mdc dialog?

@crisbeto

Copy link
Copy Markdown
MemberAuthor

I haven't looked into the MDC dialog since somebody else implemented it.

@josephperrott

Copy link
Copy Markdown
Member

@crisbeto Looks like this PR has fallen out of date, can you please rebase the PR.

@josephperrottjosephperrott removed the action: merge The PR is ready for merge by the caretaker label Nov 19, 2021
@andrewseguinandrewseguin removed the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 29, 2021
@googlebotgooglebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Dec 29, 2021
@andrewseguinandrewseguin removed the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Mar 28, 2022
@josephperrottjosephperrott added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed needs rebase labels Nov 16, 2022
@Mikastark

Copy link
Copy Markdown

Hope this PR is not abandoned and will be merged someday

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

Labels

action: cleanupThe PR is in need of cleanup, either due to needing a rebase or in response to comments from reviewscla: yesPR author has agreed to Google's Contributor License Agreementpresubmit failuresThis PR has failures in Google's internal presubmit process and cannot be immediately mergedtarget: patchThis PR is targeted for the next patch release

Projects

None yet

18 participants

@crisbeto@dinamix1@pharv@Devvox93@tammysock@swftvsn@jelbourn@rkrzewski@josephperrott@jpike88@MaximoB@akvaliya@charsleysa@AlexElin@Mikastark@googlebot@mmalerba@andrewseguin