Skip to content

Conversation

@ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Feb 19, 2025

Description

Resolves #4827

By default, when setting on_tap_outside_bar, clicking outside the bar will trigger the event but not unfocus the field. Why?

SearchBar.blur() provides the user the possibility to programmatically unfocus the bar.

Test Code

import flet as ft


def main(page: ft.Page):
    def handle_tap_outside_bar(e):
        # ...
        sb.blur()

    page.add(
        sb := ft.SearchBar(on_tap_outside_bar=handle_tap_outside_bar),
    )


ft.app(main)

Summary by Sourcery

New Features:

  • Added SearchBar.blur() method to programmatically unfocus the search bar.

@FeodorFitsner FeodorFitsner merged commit f8c7baa into main Feb 19, 2025
2 of 3 checks passed
@FeodorFitsner FeodorFitsner deleted the ndonkoHenri/searchbar-blur branch February 19, 2025 03:58
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.

Implement SearchBar.blur() to programmatically unfocus the bar

3 participants