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

[BUG] code block expanding/collapsing won't work well in non-first Shortcode tabs/tab. #1406

Closed
lvliangxiong opened this issue Dec 19, 2024 · 9 comments · Fixed by #1407
Closed
Labels
bug Something isn't working

Comments

@lvliangxiong
Copy link

Describe the bug 描述你遇到的错误

When render md file with following content:

{{< tabs >}}

{{% tab title="index.js" %}}

first tab code block

{{% /tab %}}


{{% tab title="index.js" %}}

second tab code block

{{% /tab %}}

, second tab code block expanding/collapsing won't work well when click the title bar.

But if you turn on/off the code wrap button once, the expanding/collapsing function becomes normal.

Look like chroma.style.maxHeight = chroma.scrollHeight + 10 + "px"; in theme.ts:896 failed to get scrollHeight for code blocks in other tabs. So it's limited to 10px.

20241219-134509

Expected behavior 期待的行为

Code block expand/collapse normally.

Screenshots 屏幕截图

No response

Build Environment 构建环境

  • macos intel 15.2 (24C101)
  • hugo v0.139.4+extended+withdeploy darwin/amd64 BuildDate=2024-12-09T17:45:23Z VendorInfo=brew
  • theme version: "0.4.X" latest commit

Preview Environment 预览环境

  • macos intel 15.2 (24C101)
  • chrome Version 131.0.6778.140 (Official Build) (x86_64)

Additional Information 补充信息

No response

@lvliangxiong lvliangxiong added the bug Something isn't working label Dec 19, 2024
@HEIGE-PCloud
Copy link
Owner

Yeah this is a good old CSS problem for these kind of animations.

I think Chrome has a new feature that solves this easily, but it’s not available on Firefox or Safari https://developer.chrome.com/docs/css-ui/animate-to-height-auto

@lvliangxiong
Copy link
Author

Yeah this is a good old CSS problem for these kind of animations.

I think Chrome has a new feature that solves this easily, but it’s not available on Firefox or Safari https://developer.chrome.com/docs/css-ui/animate-to-height-auto

I'm not familiar with css though.
So you prefer adopting a new way to implement code block expand/collapse just like the doc you mentioned, instead of fix the reason which leads to zero scrollHeight? Any chance we can fix it with a small mod?

@HEIGE-PCloud
Copy link
Owner

I'm not familiar with css though. So you prefer adopting a new way to implement code block expand/collapse just like the doc you mentioned, instead of fix the reason which leads to zero scrollHeight? Any chance we can fix it with a small mod?

I am happy to learn more about the solution you have in mind. I don't see a small mod fixing this.

@HEIGE-PCloud
Copy link
Owner

I figure interpolate-size is a rather small mod, though unfortunately some browsers do not support it #1407
https://do-it-git-fix-code-block-pclouds-projects.vercel.app/tab-tests/#tabs-with-codeblock

@lvliangxiong
Copy link
Author

I'm not familiar with css though. So you prefer adopting a new way to implement code block expand/collapse just like the doc you mentioned, instead of fix the reason which leads to zero scrollHeight? Any chance we can fix it with a small mod?

I am happy to learn more about the solution you have in mind. I don't see a small mod fixing this.

I just comment out theme.ts:896 and theme.ts:920 on my local device testing, code block behaves normal. But I wonder wheather it'll ruin something...

@CXwudi
Copy link
Contributor

CXwudi commented Dec 19, 2024

@lvliangxiong maybe can you bring a PR and we can test it out

@HEIGE-PCloud
Copy link
Owner

I just comment out theme.ts:896 and theme.ts:920 on my local device testing, code block behaves normal. But I wonder wheather it'll ruin something...

It removes the expansion animation.

@lvliangxiong
Copy link
Author

I just comment out theme.ts:896 and theme.ts:920 on my local device testing, code block behaves normal. But I wonder wheather it'll ruin something...

It removes the expansion animation.

ok, I just launched a quick pr for your reference. Look forward to your better solution. 🫡

@HEIGE-PCloud
Copy link
Owner

As I said, this does not quite work, the expansion animation is removed

Expected:

Screen.Recording.2024-12-20.at.09.38.20.mov

Actual:

Screen.Recording.2024-12-20.at.09.38.08.mov

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
3 participants