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

chore: Use maximum available space in ui.inline instead of hardcoded constant. #1974 #2152

Merged
merged 4 commits into from
Oct 6, 2023

Conversation

mturoci
Copy link
Collaborator

@mturoci mturoci commented Oct 5, 2023

@marek-mihok - can you make a code review and a thorough QA to check if everything works as expected?

This is a rewrite of #1988 for #1974.

The reason some components shrunk drastically was wrong use of default align='center for case when direction='column'. This PR sets the following defaults:

  • All components should try to occupy all the available space unless explicitly specified otherwise. This rule is in sync with regular form_card.items.
  • The above default does not apply for cases when explicit alignment for main axis (justify) is chosen. In such case, the default width should correspond to the component's content, be it a label or anything else.

@mturoci mturoci requested a review from lo5 as a code owner October 5, 2023 13:23
@mturoci mturoci changed the title chore: Use maximum available space in ui.inline instead of hardcoded constant. chore: Use maximum available space in ui.inline instead of hardcoded constant. #1974 Oct 5, 2023
Copy link
Contributor

@marek-mihok marek-mihok left a comment

Choose a reason for hiding this comment

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

Only one fix is needed and it's good to go, @mturoci !

ui/src/form.tsx Outdated Show resolved Hide resolved
@marek-mihok
Copy link
Contributor

@mturoci, my QA efforts has continued also after the review and brought the new finding that two of our examples using ui.inline need adjustment to new changes:

  • background_progress.py
image image
  • form_visibility.py
image image

Our Tour and Wave University apps are intact.
I'll further continue with my QA and let you know if something pops up.

@mturoci
Copy link
Collaborator Author

mturoci commented Oct 6, 2023

Perfect. Those are expected and simple to fix. Good job nonetheless. Will fix in a sec.

@marek-mihok
Copy link
Contributor

marek-mihok commented Oct 6, 2023

@mturoci, I hope this is the last one - if the user sets a fixed width for the element, it should not shrink to fit the available space (in 0:04 is the correct behavior, in 0:14 it is not):

Screen.Recording.2023-10-06.at.11.22.40.mov

@marek-mihok
Copy link
Contributor

marek-mihok commented Oct 6, 2023

@mturoci, the similar problem as previous one, but with fixed height of the element when inline direction is column. When height of the ui.inline is lower than its content, the content does not shrink and there is no scrollbar either, it simply visibly overflows:

image

The example from the screenshot is this one with visualization part modified:

        ui.inline(direction='column', height='400px', items=[
            ui.visualization(
                height='500px',
                plot=ui.plot([ui.mark(type='interval', x='=product', y='=price', y_min=0)]),
                data=data(fields='product price', rows=[(c, x) for c, x, _ in [f.next() for _ in range(n)]], pack=True),
            ),
            ui.vega_visualization(
                height='500px',
                specification=spec,
                data=data(fields=["a", "b"], rows=[
                    ["A", rnd()], ["B", rnd()], ["C", rnd()],
                    ["D", rnd()], ["E", rnd()], ["F", rnd()],
                    ["G", rnd()], ["H", rnd()], ["I", rnd()]
                ], pack=True),
            ),
        ]),

@mturoci
Copy link
Collaborator Author

mturoci commented Oct 6, 2023

The code above seems incorrect as it sets the height of the container ui.inline=(height='400px') and then wants to put there 2 500px plots, which naturally results in an overflow. Simply removing the container height should be enough.

@marek-mihok
Copy link
Contributor

marek-mihok commented Oct 6, 2023

Simply removing the container height should be enough.

In that case it's all from my side. I've also checked if everything works the same way across all 3 browsers. If you don't have anything else for me to test, I'll finish my QA.

@mturoci
Copy link
Collaborator Author

mturoci commented Oct 6, 2023

Thanks @marek-mihok!

@mturoci mturoci force-pushed the chore/default-inline-width-rewrite branch from f5bffbe to 940273a Compare October 6, 2023 11:23
@mturoci mturoci merged commit 45afd23 into main Oct 6, 2023
2 checks passed
@mturoci mturoci deleted the chore/default-inline-width-rewrite branch October 6, 2023 11: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.

2 participants