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

fix: Dropdown.alignment not respected #3737

Merged
merged 3 commits into from
Aug 5, 2024
Merged

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Jul 30, 2024

Fixes #3734

Test Code

import flet as ft


def main(page: ft.Page):
    def handle_switch_change(e):
        dd.options_fill_horizontally = e.control.value
        page.update()

    def handle_dropdown_change(e: ft.ControlEvent):
        if e.data == "top_center":
            dd.alignment = ft.alignment.top_center
        elif e.data == "top_left":
            dd.alignment = ft.alignment.top_left
        elif e.data == "top_right":
            dd.alignment = ft.alignment.top_right
        elif e.data == "center":
            dd.alignment = ft.alignment.center
        elif e.data == "center_left":
            dd.alignment = ft.alignment.center_left
        elif e.data == "center_right":
            dd.alignment = ft.alignment.center_right
        elif e.data == "bottom_center":
            dd.alignment = ft.alignment.bottom_center
        elif e.data == "bottom_left":
            dd.alignment = ft.alignment.bottom_left
        elif e.data == "bottom_right":
            dd.alignment = ft.alignment.bottom_right

        page.update()

    dd = ft.Dropdown(
        label="Select an option",
        value="top_left",
        options=[
            ft.dropdown.Option(text="top_left"),
            ft.dropdown.Option(text="top_center"),
            ft.dropdown.Option(text="top_right", alignment=ft.alignment.top_right),
            ft.dropdown.Option(text="center_left"),
            ft.dropdown.Option(text="center"),
            ft.dropdown.Option(
                text="center_right", alignment=ft.alignment.center_right
            ),
            ft.dropdown.Option(text="bottom_left"),
            ft.dropdown.Option(text="bottom_center"),
            ft.dropdown.Option(text="bottom_right"),
        ],
        alignment=ft.alignment.top_left,
        options_fill_horizontally=False,
        on_change=handle_dropdown_change,
    )

    page.add(dd, ft.Switch("Options Fill Horizontally", on_change=handle_switch_change))


ft.app(target=main)

Summary by Sourcery

This pull request fixes the issue where Dropdown.alignment was not being respected. It also introduces enhancements by adding support for options_fill_horizontally and disabled_hint_content properties in the Dropdown component.

  • Bug Fixes:
    • Fixed the issue where Dropdown.alignment was not being respected.
  • Enhancements:
    • Added support for options_fill_horizontally and disabled_hint_content properties in the Dropdown component.

Copy link
Contributor

sourcery-ai bot commented Jul 30, 2024

Reviewer's Guide by Sourcery

This pull request addresses the issue where the Dropdown.alignment property was not being respected. The changes include adding new properties options_fill_horizontally and disabled_hint_content to the Dropdown class, and updating the relevant methods and attributes to handle these new properties. Additionally, the Dart implementation of the dropdown control has been updated to support these new properties.

File-Level Changes

Files Changes
sdk/python/packages/flet-core/src/flet_core/dropdown.py
packages/flet/lib/src/controls/dropdown.dart
Introduced new properties options_fill_horizontally and disabled_hint_content to the Dropdown class and updated both Python and Dart implementations to support these properties.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ndonkoHenri - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Bug: Incorrect content added to children list (link)

Overall Comments:

  • Consider adding more comprehensive unit tests to cover the new functionality, especially for the new properties like options_fill_horizontally and disabled_hint_content.
  • It would be beneficial to update the documentation to reflect the new properties and their usage in the Dropdown component.
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@flet-dev flet-dev deleted a comment from sourcery-ai bot Jul 30, 2024
@flet-dev flet-dev deleted a comment from sourcery-ai bot Jul 30, 2024
@FeodorFitsner
Copy link
Contributor

Could you resolve conflict here please?

# Conflicts:
#	packages/flet/lib/src/controls/dropdown.dart
@FeodorFitsner FeodorFitsner merged commit 7f0cdb4 into main Aug 5, 2024
2 checks passed
@ndonkoHenri ndonkoHenri deleted the fix-dropdown-alignment branch August 5, 2024 19:42
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.

Alignment on DropDown not working
2 participants