Skip to content

Conversation

@Dolov
Copy link
Contributor

@Dolov Dolov commented Jun 21, 2021

@vercel
Copy link

vercel bot commented Jun 21, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/react-component/collapse/CG9sjeo1zNLY1GdejxZRRyGWFPQb
✅ Preview: https://collapse-git-fork-dolov-master-react-component.vercel.app

@codecov
Copy link

codecov bot commented Jun 22, 2021

Codecov Report

Merging #215 (08ea239) into master (98af802) will increase coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
src/Panel.tsx 97.22% <100.00%> (+0.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98af802...08ea239. Read the comment docs.

src/Panel.tsx Outdated
<div
className={headerCls}
onClick={() => collapsible !== 'header' && this.handleItemClick()}
onClick={() => !collapsibleHeader && this.handleItemClick()}
Copy link
Member

@kerm1it kerm1it Jun 22, 2021

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 做处理?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这样会比较灵活,不用每次都在外面包裹元素处理

Copy link
Contributor Author

@Dolov Dolov Jun 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那就是把 jsx 中的判断逻辑都提取至 handleItemClick 方法中 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以在这里判断或者另写一个方法,handleItemClick 尽量不要变

Copy link
Member

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}
Copy link
Member

@afc163 afc163 Jun 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当指定 collapsible="header" 时,这里的 role 和 tabIndex 都不需要了。因为不再是可交互元素。

@afc163 afc163 merged commit a9d2a52 into react-component:master Sep 14, 2021
MadCcc added a commit that referenced this pull request Apr 8, 2022
This reverts commit a9d2a52.
MadCcc added a commit that referenced this pull request Apr 8, 2022
MadCcc added a commit that referenced this pull request Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collapse 组件在 collapsible='header' 模式下点击图标无法收起展开

3 participants