-
Notifications
You must be signed in to change notification settings - Fork 141
fix: 31039 #215
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
fix: 31039 #215
Conversation
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/react-component/collapse/CG9sjeo1zNLY1GdejxZRRyGWFPQb |
Codecov Report
@@ Coverage Diff @@
## master #215 +/- ##
==========================================
+ Coverage 98.13% 98.21% +0.08%
==========================================
Files 4 4
Lines 107 112 +5
Branches 33 33
==========================================
+ Hits 105 110 +5
Misses 2 2
Continue to review full report at Codecov.
|
src/Panel.tsx
Outdated
| <div | ||
| className={headerCls} | ||
| onClick={() => collapsible !== 'header' && this.handleItemClick()} | ||
| onClick={() => !collapsibleHeader && this.handleItemClick()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
能不能在这里判断一下 event.target 如果是 header 本身,说明是点击了其他区域,如果不是就是点击了 icon、header 文字或 extra
然后根据上面的结果结合 collapsibleHeader 做处理?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样会比较灵活,不用每次都在外面包裹元素处理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那就是把 jsx 中的判断逻辑都提取至 handleItemClick 方法中 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以在这里判断或者另写一个方法,handleItemClick 尽量不要变
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里解决了么?
src/Panel.tsx
Outdated
| onClick={() => collapsible !== 'header' && this.handleItemClick()} | ||
| onClick={() => !collapsibleHeader && this.handleItemClick()} | ||
| role={accordion ? 'tab' : 'button'} | ||
| tabIndex={disabled ? -1 : 0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当指定 collapsible="header" 时,这里的 role 和 tabIndex 都不需要了。因为不再是可交互元素。
close ant-design/ant-design#31039