ionic-team / ionic-team/ionic-framework

feat: add event for clicking on searchbar search icon

未关闭
#19,997 7 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看
package: core type: feature request
主要语言
TypeScript
星标
52.7k
派生
13.3k
平均合并
1 天 15 小时
30 天内合并 PR
51

描述

# Feature Request
I'd like to have a possibility to assign an event listener to searchbar icon

**Ionic version:**

[x] **4.x**

**Describe the Feature Request**

I have the angular (search) eventListener, but it would only be firing when we click enter on the ion-searchbar. When we click on the search icon nothing happens. What I would like to happen is actually the same search action

**Describe Preferred Solution**

The easiest way would be to have defined a search event and that event would apply on enter and on clicking the search icon.

**Describe Alternatives**

Another one way would be just allowing to define an event when clicking the icon. It that case we can still use (search) from search bar, but also an event listener for the search icon.

**Related Code**

**Additional Context**

I've seen this solution https://forum.ionicframework.com/t/ionic-search-bar-search-icon-clicked/77072/4 which implies using elementRef, but not sure if this is a great solution because of the fact that those listeners could leak if not removed, etc.

Also I've read about HostListener, but when I add it to the searchbar and set click event, it is always showing as event target the searchbar (even when I click on the icon itself)

贡献指南

打开贡献指南

调研方向

Start by tracing ion-searchbar's existing (search) event and the search-icon click path, comparing them with Enter-key behavior. Done means clicking the icon triggers the intended search action or exposes the requested event consistently, with coverage for both interaction paths.

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。