Skip to content

Expose onTapOutside from SearchBar's TextField #145096

Closed

Description

@aleripe

Use case

All the TextFields in my app are set to lose focus closing the keyboard when they're tapped outside. I can't do the same on SearchBar as the onTapOutside property of TextField class is not exposed.

Proposal

Introduce onTextOutside parameter for SearchBar and SearchAnchor constructors.

Activity

  1. added
    in triagePresently being triaged by the triage team
    c: new featureNothing broken; request for a new capability
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    c: proposalA detailed proposal for a change to Flutter
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Mar 14, 2024
  2. Sahil-kachhap commented on Mar 15, 2024

    @Sahil-kachhap
    Contributor

    Use case

    All the TextFields in my app are set to lose focus closing the keyboard when they're tapped outside. I can't do the same on SearchBar as the onTapOutside property of TextField class is not exposed.

    Proposal

    Introduce onTextOutside parameter for SearchBar and SearchAnchor constructors.

    Do you have any other use cases (other than losing the focus) for which you want the onTapOutside parameter to be exposed by the Searchbar constructor?
    If you only want to unfocus it on being tapped outside, this can be implemented internally in the search bar class, and then there would be no need to expose the parameter.

  3. Sahil-kachhap commented on Mar 15, 2024

    @Sahil-kachhap
    Contributor
    WhatsApp.Video.2024-03-15.at.6.59.45.PM.mp4

    Here's a fix I have implemented @danagbemava-nc @darshankawar, Let me know if this looks good to go.
    And here's what I have done: I utilize the focusNode property of searchbar class and then I use it in onTapOutside property of underlying textfield.

    onTapOutside: _focusNode.unfocus();
    

    the change has been made here - just added a parameter: onTapOutside

  4. aleripe commented on Mar 18, 2024

    @aleripe
    Author

    Use case

    All the TextFields in my app are set to lose focus closing the keyboard when they're tapped outside. I can't do the same on SearchBar as the onTapOutside property of TextField class is not exposed.

    Proposal

    Introduce onTextOutside parameter for SearchBar and SearchAnchor constructors.

    Do you have any other use cases (other than losing the focus) for which you want the onTapOutside parameter to be exposed by the Searchbar constructor? If you only want to unfocus it on being tapped outside, this can be implemented internally in the search bar class, and then there would be no need to expose the parameter.

    I have no other use case at the moment, but I think it could be more useful to expose it rather than wrap it. But it's your choice!

  5. CicciLeo commented on Mar 19, 2024

    @CicciLeo

    Use case

    All the TextFields in my app are set to lose focus closing the keyboard when they're tapped outside. I can't do the same on SearchBar as the onTapOutside property of TextField class is not exposed.

    Proposal

    Introduce onTextOutside parameter for SearchBar and SearchAnchor constructors.

    Do you have any other use cases (other than losing the focus) for which you want the onTapOutside parameter to be exposed by the Searchbar constructor? If you only want to unfocus it on being tapped outside, this can be implemented internally in the search bar class, and then there would be no need to expose the parameter.

    It can be usefull if you want to clear the SearchController value if you tap outside, and keep the text only on submit

  6. Sahil-kachhap commented on Mar 19, 2024

    @Sahil-kachhap
    Contributor

    Thanks @aleripe @CicciLeo for sharing this usecase, I will make the relevant changes in the PR based on your responses.

  7. added a commit that references this issue on Mar 25, 2024
    a9f18b8
  8. github-actions commented on Apr 9, 2024

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions