-
-
Notifications
You must be signed in to change notification settings - Fork 156
Fix(#515): ShadDialog always expands to constraints.maxWidth #516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe dialog widget is wrapped with an IntrinsicWidth container to ensure the dialog measures its width based on its content's natural dimensions rather than expanding to maximum constraints. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes This is a minimal, localized UI hierarchy change with no public API modifications or logic alterations. Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying shadcn-ui-playground with
|
Latest commit: |
ab2b0bf
|
Status: | ✅ Deploy successful! |
Preview URL: | https://332df545.shadcn-ui-playground.pages.dev |
Branch Preview URL: | https://fix-dialog-constraints.shadcn-ui-playground.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using IntrinsicWidth
isn't a solution. The problem is somewhere else.
It may not be the solution BUT at least it's a temporary fix. |
well well, if only I opened the docs early. // in material/dialog.dart
Widget dialogChild = IntrinsicWidth( // <----
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: columnChildren,
),
); THe issue is the child of this IntrinsicWidth widget, which is a column (same as our design), will always expand horizontally, idk why. So an |
Tomorrow I'll try to figure out what is going wrong and I'll give an update |
it's ok take ur time but I tried literally every possible thing. I mean the Flutter team also used IntrinsicWidth. |
It's very strange they are using it for a simple Column. Usually using InstrinsicWidth or IntrisicHeight is a bad practice. |
first this is a good summary I found it helpful https://www.youtube.com/watch?v=Si5XJ_IocEs.
I wouldn't say it's a "bad practice" but more like a "use-with-caution" tool.
We also default to |
Docs of Material
Related issue on this matter: I think we can add a boolean flag that disable the usage of |
For future reference I was confused why the
But I finally understand what happens here. Starting from the rule "Constraints go down. Sizes go up. Parent sets position."
And this's the part I was understanding wrong
what does this mean? // flex.dart
BoxConstraints _constraintsForNonFlexChild(BoxConstraints constraints) {
final bool fillCrossAxis = switch (crossAxisAlignment) {
CrossAxisAlignment.stretch => true, <-----------
CrossAxisAlignment.start ||
CrossAxisAlignment.center ||
CrossAxisAlignment.end ||
CrossAxisAlignment.baseline => false,
};
return switch (_direction) {
Axis.horizontal =>
fillCrossAxis
? BoxConstraints.tightFor(height: constraints.maxHeight)
: BoxConstraints(maxHeight: constraints.maxHeight),
Axis.vertical => <--------------
fillCrossAxis
? BoxConstraints.tightFor(width: constraints.maxWidth) <-------
: BoxConstraints(maxWidth: constraints.maxWidth),
};
}
|
TODO:
|
closes #515
Pre-launch Checklist
///
).0.18.0
and you introduced a breaking change or a new feature, bump it to0.19.0
, if you just added a fix or a chore bump it to0.18.1
.CHANGELOG.md
file with a summary of changes made following the format already used.If you need help, consider asking for advice on Discord.
Summary by CodeRabbit