Skip to content

SearchControl always shows the close icon when onClose prop is set #64921

@Sidsector9

Description

@Sidsector9

Description

The SearchControl component has an icon suffix to show a magnifying lens or the close icon conditionally.
But when the onClose prop is set, the lens icon is never shown, and the close icon is always shown.

Step-by-step reproduction instructions

<SearchControl
    value={ text }
    onChange={ setText }
    onClose={ () => {} } // comment and uncomment this line to observe the bug.
/>

Expected behavior

  1. When onClose is not set, the search icon should be always shown (for empty and non-empty field)
  2. When onClose is set, then the close icon should be shown when the field is not empty, and search icon should be shown when the field is empty.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Metadata

Metadata

Assignees

Labels

[Package] Components/packages/components[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions