Skip to content

[Ionic4] Disabled searchbar #17921

Closed
Closed

Description

@KyDenZ

Feature Request

Ionic version:
[x] 4.x

Describe the Feature Request
Hello,
Ionic 3 does not offer the possibility to disable an ion-searchbar, with ionic 4 it is still not possible.

But there was a technique to make it disabled in OnInit:

const ionSearchBarInputBox: any = this.searchBar.nativeElement.querySelector('input');
ionSearchBarInputBox.disabled = true;

Except with Ionic 4 this technique does not work anymore. The input element is not generated at the time of ngOnInit or ngAfterViewInit
You have to put these lines of code in a setTimeout of 500 for it to work. Which is not stable.

Describe Preferred Solution
The input should be disabled at the time of its generation

Describe Alternatives
It would be nice to have a disabled attribute as on other input to disable easily

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.1.1
   @angular-devkit/build-angular : 0.13.6
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.3.6
   @ionic/angular-toolkit        : 1.4.0

Capacitor:

   capacitor (Capacitor CLI) : 1.0.0-beta.19
   @capacitor/core           : 1.0.0-beta.19

System:

   NodeJS : v10.15.0 (/usr/local/bin/node)
   npm    : 6.4.1
   OS     : macOS Mojave

Thanks!

Activity

  1. added
    type: feature request
    package: core
    on Apr 1, 2019
  2. added
    help wanted
    on Apr 2, 2019
  3. ionitron-bot commented on Apr 2, 2019

    @ionitron-bot

    This issue has been labeled as help wanted. This label is added to issues that we believe would be good for contributors.

    If you'd like to work on this issue, please comment here letting us know that you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort.

    For a guide on how to create a pull request and test this project locally to see your changes, see our contributing documentation.

    Thank you!

  4. KyDenZ commented on Apr 10, 2019

    @KyDenZ
    Author

    @masimplo it's a good reflection
     
    I just tested by adding the attribute "showCancelButton" with a default value. The cancel button is not visible, which seems fine to me. If the field is disabled, we must not be able to change its content. Finally it's my point of view.

  5. masimplo commented on Apr 10, 2019

    @masimplo
    Contributor

    Oh forks... I accidentally deleted my previous comment trying to edit it and cannot get it back :(
    Anyway, yes I was mostly referring to the fact that the searchbar input is more complicated than other inputs since it has more than one components (i.e. clear and cancel) You are correct that cancel and clear buttons are not visible when the focus is lost, which is what happens if the input is disabled anyway, so there should be no issue there.

  6. AlekNiebla commented on Apr 20, 2019

    @AlekNiebla

    Hey can I take a look at this issue?

  7. KyDenZ commented on Apr 21, 2019

    @KyDenZ
    Author

    The pull request has been sent

  8. added 4 commits that reference this issue on May 8, 2019
    5eb942f
    71d5400
    2c24df2
    9c65d5d
  9. ionitron-bot commented on May 22, 2019

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

  10. locked and limited conversation to collaborators on May 22, 2019
  11. added a commit that references this issue on May 22, 2019
    3da7254
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

    help wantedpackage: coretype: feature request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions