Skip to content
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

YaruAutocomplete: calculate matching options width by default #673

Merged
merged 1 commit into from
Mar 13, 2023
Merged

YaruAutocomplete: calculate matching options width by default #673

merged 1 commit into from
Mar 13, 2023

Conversation

jpnurmi
Copy link
Member

@jpnurmi jpnurmi commented Mar 13, 2023

Flutter's Autocomplete widget expands the options popup to all available width. Given that it looks somehow unusual on desktop, we made it possible to override the width in #668.

Most often, the autocomplete widget can be simply wrapped with a LayoutBuilder to get the width but things get more complicated when trying to use it in a dialog because LayoutBuilder naturally doesn't support intrinsic sizes. Therefore, I'm proposing to make this the default behavior and let YaruAutocomplete calculate the matching width under the hood. The old behavior is still possible by e.g. passing the screen width or simply optionsWidth: double.infinity.

Before After
Screenshot from 2023-03-13 10-44-25 Screenshot from 2023-03-13 10-44-08

Copy link
Member

@Jupi007 Jupi007 left a comment

Choose a reason for hiding this comment

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

I see you're using a post frame callback, but isn't it creating a size jump during a frame?

Also, there isn't any page for this widget in the example app, is it intentional?

@jpnurmi
Copy link
Member Author

jpnurmi commented Mar 13, 2023

I see you're using a post frame callback, but isn't it creating a size jump during a frame?

There's no render box until the widget has been rendered but notice that the popup is not visible during initState() anyway. The same approach is used by some Flutter widgets that deal with popups. :)

Also, there isn't any page for this widget in the example app, is it intentional?

I dropped it for the time being because it was too ugly to be the starting page 😀

#668

Copy link
Member

@Jupi007 Jupi007 left a comment

Choose a reason for hiding this comment

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

There's no render box until the widget has been rendered but notice that the popup is not visible during initState() anyway. The same approach is used by some Flutter widgets that deal with popups. :)

Okay, that's perfect so 👍 🙂

I dropped it for the time being because it was too ugly to be the starting page grinning

Oh, I didn't noticed this commit, maybe would it be a better solution to make the default page at a different index, is it possible currently?

@jpnurmi
Copy link
Member Author

jpnurmi commented Mar 13, 2023

For reference, LayoutBuilder works fine here:

image

But it explodes when used in a dialog like this that relies on intrinsic sizes:

image

@Jupi007
Copy link
Member

Jupi007 commented Mar 13, 2023

But it explodes when used in a dialog like this that relies on intrinsic sizes:

Wow, yeah this is not how it should look 😅

@jpnurmi
Copy link
Member Author

jpnurmi commented Mar 13, 2023

Oh, I didn't noticed this commit, maybe would it be a better solution to make the default page at a different index, is it possible currently?

Good idea! 👍 I think it should be possible yeah. Should we keep the banner page as the default or what is the most representative page?

@jpnurmi jpnurmi merged commit aba3ce8 into ubuntu:main Mar 13, 2023
@jpnurmi jpnurmi deleted the autocomplete-options-width branch March 13, 2023 10:22
@Jupi007
Copy link
Member

Jupi007 commented Mar 13, 2023

Imo the banner page is the best candidate for a default page 👍
We can set the default index with a YaruPageController.

@jpnurmi jpnurmi mentioned this pull request Mar 13, 2023
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.

None yet

2 participants