flet-dev / flet

Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
https://flet.dev
Apache License 2.0
9.45k stars 362 forks source link

textfiled in listtile bug #3252

Closed BrentHuang closed 1 week ago

BrentHuang commented 1 week ago

Description

Code example to reproduce the issue:

# -*- coding: utf-8 -*-

import flet as ft

def main(page: ft.Page):
    page.add(
        ft.ListTile(
            title=ft.Text('Hotkeys'),
            trailing=ft.TextField(
                width=150,
                hint_text=''.join(['Search', '...']),
                prefix_icon=ft.icons.SEARCH,
                max_lines=1,
                autofocus=True)))

ft.app(target=main)

Describe the results you received: When the length of the input exceeds the length of textfiled, only half of the text is displayed. image

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Flet version (pip show flet):

0.22.0

Give your requirements.txt file (don't pip freeze, instead give direct packages):

no

Operating system:

Windows 10

Additional environment details:

BrentHuang commented 1 week ago

Adding max_length=100 to the textfield is even weirder. image

ndonkoHenri commented 1 week ago

Read this: https://python.plainenglish.io/how-to-resize-flets-textfield-control-without-the-content-going-invisible-6d268a4d96e1

BrentHuang commented 1 week ago

why content_padding=ft.Padding(left=5, top=3, right=5, bottom=3) ?

This is not the ultimate solution and seems mysterious. There is something wrong with the default parameters. I seem to have never encountered such a problem in other libraries.

BrentHuang commented 1 week ago

Adding max_length=100 to the textfield is even weirder. image

here why does the input box become flat? contet_padding has been added as you said.

ndonkoHenri commented 1 week ago

here why does the input box become flat?

The text field alone has at the beginning a default height, and the counter_text you added takes up some of this height/space inorder to be properly displayed. You can increase the height of textfield control using the height property.

content_padding is the solution to the textfield's content/text going partly/completely invisible.