Skip to content

TextField. Property height doesn't work properly #4106

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

Closed
1 task done
ClearSafety opened this issue Oct 5, 2024 · 2 comments · Fixed by #4105
Closed
1 task done

TextField. Property height doesn't work properly #4106

ClearSafety opened this issue Oct 5, 2024 · 2 comments · Fixed by #4105
Assignees
Labels
controls enhancement Improvement/Optimization

Comments

@ClearSafety
Copy link

ClearSafety commented Oct 5, 2024

Duplicate Check

Describe the bug

TextField has the properties height and width that do not figure in the documentation.
There's an issue with the property height, that works only to decrease the height of the field.
The solution of the discussion 2345 is not very good, because it suggests you one uses the min_line to increase the field hight. It works, but it's not possible to have the control of the size in pixels, for instance.
Currently, as I could see, there's no way to have a single line field with its height customized in pixels by the developer.

#2345

Code sample

Code
import flet as ft

def main(page: ft.Page):
    
    page.add(
        ft.TextField(
            height=100,
            width=100,
        )
    )

ft.app(target=main, view=ft.AppView.WEB_BROWSER)

To reproduce

  1. Run the reprocode

Expected behavior

It was expected the field increase its height size according to the value passed to the 'height' property.

Screenshots / Videos

Captures

[Upload media here]

Operating System

Windows

Operating system details

Windows 11 Pro

Flet version

0.24.1

Regression

No, it isn't

Suggestions

Add the properties 'width' and 'height' to the documentation.
Enable the 'height' property to increase the size of the field, the same as it's possible with the CupertinoTextField.

Logs

Logs
[Paste your logs here]

Additional details

No response

@ndonkoHenri ndonkoHenri added enhancement Improvement/Optimization controls labels Oct 6, 2024
@ndonkoHenri ndonkoHenri linked a pull request Oct 6, 2024 that will close this issue
FeodorFitsner added a commit that referenced this issue Oct 29, 2024
* nav bar/drawer/rail

* TooltipDirection enum has wrong values

* Text and TextSpan

* GestureDetector

* deprecate MapPointerDeviceType in favor of PointerDeviceType

* create BoxConstraints dataclass

* update utils

* fix navbar appearance when disabled

* PopupMenu new props

* move AnimationValue from types.py to animation.py

* update

* Tab: icon_content, height, icon_margin

* New props: TextField, Dropdown, CupertinoTextField

* FormField: make suffix_icon and prefix_icon support both string and Control types

* refactor ControlState props

* properly disable navbar

* fix failing CI: NoneType is not available in py3.8

* fix failing CI: update expected test value

* fix failing CI: import ControlState

* FormField: add `collapsed` prop which fits field's content (#4106)

* remove _set_control_state_attr_json; add wrap_attr_dict boolean prop to _set_attr_json

* FormField: fit_parent_size prop

* Define __post_init__ method for Dataclasses making use of ControlState

* remove Optional in AnimationValue

* `FormField.label` as a Control

* Fix wrapping ListTile to Material widget

(do not wrap if it's cupertino)

---------

Co-authored-by: Feodor Fitsner <[email protected]>
@ClearSafety
Copy link
Author

@FeodorFitsner , even using now the Version: 0.25.0.dev3614, I'm afraid the 'height' property of the control TextField is still not working. It only increases the area occupied by the TextField in the page. The same behaviour of the margin applied in the botton.

textfield

@ndonkoHenri
Copy link
Contributor

ndonkoHenri commented Oct 31, 2024

@ClearSafety here s an example:

 import flet as ft


def main(page: ft.Page):
    page.theme_mode = ft.ThemeMode.LIGHT

    def handle_slider_change(e: ft.ControlEvent):
        field_1.height = e.control.value
        field_2.height = e.control.value
        page.update()

    page.add(
        ft.Slider(
            value=70,
            min=70,
            max=300,
            divisions=20,
            on_change=handle_slider_change,
        ),
        ft.Row(
            controls=[
                field_1 := ft.TextField(
                    label="fit_parent_size",
                    fit_parent_size=True,
                    height=70,
                ),
                field_2 := ft.TextField(
                    label="fit_parent_size + collapsed + content_padding",
                    fit_parent_size=True,
                    height=70,
                    collapsed=True,  # helps aligns the text in the field to the top vertically
                    content_padding=15,
                ),
            ]
        ),
    )


ft.app(target=main)

In brief, you need to set fit_parent_size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
controls enhancement Improvement/Optimization
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants