Skip to content

fix: [code-block] stop adding a hidden line to maxLines - #927

Merged
rohanchkrabrty merged 2 commits into
mainfrom
fix/code-block-max-lines
Oct 1, 2026
Merged

rohanchkrabrty merged 2 commits into
mainfrom
fix/code-block-max-lines

Conversation

@rohanchkrabrty

Copy link
Copy Markdown
Contributor

Summary

  • CodeBlock stored maxLines + 1 in context and rendered one extra line behind the absolutely positioned collapse trigger. Without a CollapseTrigger, maxLines={5} showed 6 lines.
  • Pass maxLines through as given. CollapseTrigger renders when the code has more than maxLines lines.
  • Keep the collapsed trigger in normal flow and remove the code's bottom padding while collapsed, so the cut looks the same. The trigger also lines up when it sits outside CodeBlock.Content, as in the docs anatomy.
  • Keep index keys for lines and tokens: they are position-based and stateless. Keep the 0.5px borders, which the design system uses on purpose.

Closes #606

The collapsed trigger covered the bottom of the code, so the root passed maxLines + 1 and rendered a hidden extra line. Without a trigger, maxLines={5} showed 6 lines. The collapsed trigger now sits in normal flow and the code drops its bottom padding while collapsed.
@vercel

vercel Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
apsara Ready Ready Preview Oct 1, 2026 7:46am UTC

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 728f985a-6fd2-4ffa-bdbf-ac2b51f46afb

📥 Commits

Reviewing files that changed from the base of the PR and between d088032 and 74bb524.

📒 Files selected for processing (4)
  • packages/raystack/components/code-block/__tests__/code-block.test.tsx
  • packages/raystack/components/code-block/code-block-misc.tsx
  • packages/raystack/components/code-block/code-block-root.tsx
  • packages/raystack/components/code-block/code-block.module.css
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/@raystack/apsara@927

commit: 74bb524

Comment thread packages/raystack/components/code-block/code-block-misc.tsx Outdated
@rohanchkrabrty
rohanchkrabrty merged commit c871c8d into main Oct 1, 2026
6 of 8 checks passed
@rohanchkrabrty
rohanchkrabrty deleted the fix/code-block-max-lines branch October 1, 2026 07:43

This branch was successfully deployed

1 active deployment
Preview — 74bb5246 Deployed Oct 1, 2026 by vercel[bot]
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.

[CodeBlock] Fix token rendering and sub-pixel border

2 participants