Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dropdown 下拉菜单] 添加菜单展开/收起的回调 #2989

Open
jrainlau opened this issue Jul 11, 2024 · 7 comments
Open

[Dropdown 下拉菜单] 添加菜单展开/收起的回调 #2989

jrainlau opened this issue Jul 11, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@jrainlau
Copy link

这个功能解决了什么问题

在自定义下拉框内容的场景中,很多时候需要知晓菜单的展开/收起时机,以便实现对应的逻辑。举个例子:
image
类似这种菜单的功能,为了优化性能,我希望在完成全部的勾选项,关闭菜单后,才触发一次后台请求。现在没有展开/收起的回调,我只能操作一个就往后台发一次请求。

你建议的方案是什么

给 添加 onShowonHide 回调,分别在展示菜单、关闭菜单时触发。

Copy link
Contributor

👋 @jrainlau,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@HaixingOoO HaixingOoO added the enhancement New feature or request label Jul 11, 2024
@NWYLZW
Copy link
Collaborator

NWYLZW commented Jul 11, 2024

加个 onTrigger 怎么样

interface Props {
  onTrigger?: (action: 'show' | 'hide') => void
}

@HaixingOoO @uyarn @ZWkang

@HaixingOoO
Copy link
Collaborator

HaixingOoO commented Jul 11, 2024

加个 onTrigger 怎么样

interface Props {
  onTrigger?: (action: 'show' | 'hide') => void
}

onChange 是不是会好点?🤔

@NWYLZW
Copy link
Collaborator

NWYLZW commented Jul 11, 2024

加个 onTrigger 怎么样

interface Props {
  onTrigger?: (action: 'show' | 'hide') => void
}

onChange 是不是会好点?🤔

不好,和一般的常见语义冲突了。这里没有 value 的,来个这个给我看第一眼的话很奇怪,像是什么受控属性了。

不过这么一说或许可以加 visible, defaultVisible, onVisibleChange 三个一起的受控属性。看哪个方案更合适?

@uyarn
Copy link
Collaborator

uyarn commented Jul 11, 2024

如果一定要加的话 建议就和select一样暴露一个onPopupVisibleChange,不过现在的popupProps透传事件也可以满足这个需求,就是多了一层

@NWYLZW
Copy link
Collaborator

NWYLZW commented Jul 11, 2024

如果一定要加的话 建议就和select一样暴露一个onPopupVisibleChange,不过现在的popupProps透传事件也可以满足这个需求,就是多了一层

那回头要加的话按照统一的规则来吧。@jrainlau 你可以先使用上面说的 popupProps 来解决你现在的问题。

carolin913 added a commit that referenced this issue Jul 11, 2024
uyarn pushed a commit that referenced this issue Jul 11, 2024
* feat(breadcrumb): add tooltipprops

re #2989

* chore: update snapshot

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@jrainlau
Copy link
Author

jrainlau commented Jul 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants