feat(dialog): Specify a desired aspect ratio to improve responsiveness
Bug, feature request, or proposal:
I have a dialog that is too narrow on large screens if I don't specify a minWidth. But if I specify a minWidth, the dialog is too wide. Since the dialog's minWidth can be specified in the dialog config, it does not feel right to specify it in CSS, but with CSS I can use media queries.
What is the expected behavior?
Actually it would be best if MatDialog could avoid strange aspect ratios by itself. The dialog config could be extended by an aspect ratio property and MatDialog tries to stick to this aspect ration while making best use of the available space. This way I could specify a maxWidth and an aspect ratio and the dialog would look good on all resolutions.
What is the current behavior?
Without minWidth the dialog becomes too narrow on large screens. With minWidth I get an unnecessary horizontal scroll bar on small screens. I can use CSS, but this seems a bit wrong as there is specific property for this purpose.
What are the steps to reproduce?
The problem appears if you have a dialog with let's say 5 input field rows and a 6th row with the Save/Cancel buttons. Without a minimum width the dialog's aspect ration on large screens becomes too narrow. With a minimum width I can make the dialog look good on large screens, but then it will be too large for small screens.
What is the use-case or motivation for changing an existing behavior?
I want dialogs to look good on all screen resolutions.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 5, Material 5rc2, all major OS, Typescript 2.4, all major browsers.
Is there anything else we should know?
It's slightly counter-intuitive, but if you set the 'width' to some pixel value (e.g. 500px, 1024px) instead of trying to set 'minWidth', it might do something close what you want. The 'width' configuration acts more like a max width in practice, since the dialog will still take on a reasonable widths even when the viewport has insufficient width available. Then you can use 'maxWidth' dialog config setting to essentially control the gutter for while the viewport width is less than the 'width' value. e.g. setting 'maxWidth' to '100vw' causes there to be no gutter at all for viewport widths less than the 'width' setting. The default 'maxWidth' value of '80vw' causes some gutter to be present even at small widths.
I think with the new aspect-ratio CSS property having good support it should be possible to solve this quite easy?
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.
Find more details about Angular's feature request process in our documentation.
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.
We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.
You can find more details about the feature request process in our documentation.
Responsive behavior for the dialog is best implemented using the minWidth and maxWidth properties. I don't think that introducing an aspect ratio is going to help much, because on a narrow screen the height is going to become even narrower in order to maintain the aspect ratio.
Well. But actually I often have dialogs that tend to be extremly "flat" (low height) and on wide screens. For example if there is very few content. So I would like to have a minWidth for small devices but no maxWidth as the dialog might have a lot of content, but if it has only little content it should not use the maxWidth but use some height.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.