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

fix(collapse): improve the timing to detect panel content whether empty #184

Merged
merged 1 commit into from
Jun 18, 2021

Conversation

mortalYoung
Copy link
Collaborator

简介

  • 由于 collapse 是当 panel content 为空内容的时候,则不会展开内容。此前在 render 的时候实时去计算每一个 panel 是否是空内容,然后再去计算位置。这就会导致无法准确的判断 panel 是否为空内容,因为有可能 collapse panel 是有 HOC 的。因此,考虑修改判断 content 是否为空的逻辑。
  • 修复当 panel 为空的情况下,collapse 仍然会展开的问题。

主要变更

  • 优化判断 content 为空的时机,原来是在 render 的时候判断,移到 useLayoutEffect 里面延迟判断。
  • 通过直接调整 dom 的 style 来调整位置,即 elm.style.height 的方式改变位置。为了准确找到对应的 dom 结构,通过 data-* 使得可以准确找到对应 panel 的位置。

@mortalYoung mortalYoung added the bug Something isn't working label Jun 18, 2021
@wewoor wewoor added this to the 0.9.0-alpha.3 milestone Jun 18, 2021
@wewoor wewoor merged commit eb70c6d into main Jun 18, 2021
@wewoor wewoor deleted the fix/collapse branch June 18, 2021 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants