Skip to content

[DX-1525]: Collapse long snippets behind a "Show more" toggle#3470

Merged
m-hulbert merged 1 commit into
mainfrom
feature/codeblock-show-more
Jul 16, 2026
Merged

[DX-1525]: Collapse long snippets behind a "Show more" toggle#3470
m-hulbert merged 1 commit into
mainfrom
feature/codeblock-show-more

Conversation

@m-hulbert

Copy link
Copy Markdown
Contributor

Description

This PR collapses codeblocks by default if they are above 15 lines long, adding a 'show more' and 'show less' toggle so that it's easy to switch between them.

The intention is to improve the readability of pages with multiple, long codeblocks such as getting started guides.

Checklist

@m-hulbert m-hulbert self-assigned this Jul 13, 2026
@m-hulbert m-hulbert added the review-app Create a Heroku review app label Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 737921ec-9d51-455e-aa5e-7aadb5fbb869

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/codeblock-show-more

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.

@ably-ci ably-ci temporarily deployed to ably-docs-feature-codeb-wuhshk July 13, 2026 16:46 Inactive

@umair-ably umair-ably left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 nit... we can only calculate the height of the code blocks after the page has rendered, which in theory means all pages will load with the code blocks fully expanded, and then instantly redraw them to be collapsed if needed (which could cause a subtle flash or layout shift).

However, I've tested this across several pages in the preview app and it looks perfect - nothing funky spotted

Clip code blocks longer than 15 lines (configurable via collapsedLineCount)
behind a fade-out gradient and a "Show more"/"Show less" toggle. The toggle
is a floating centered pill rather than a full-width bordered bar, so it
never reads as a second footer row when the API key selector sits below it.
Authors can opt out per block with collapse={false}.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@m-hulbert m-hulbert force-pushed the feature/codeblock-show-more branch from 2cfafaa to 98c42af Compare July 16, 2026 11:44
@ably-ci ably-ci temporarily deployed to ably-docs-feature-codeb-wuhshk July 16, 2026 11:45 Inactive
@m-hulbert m-hulbert merged commit a8d35db into main Jul 16, 2026
7 checks passed
@m-hulbert m-hulbert deleted the feature/codeblock-show-more branch July 16, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-app Create a Heroku review app

Development

Successfully merging this pull request may close these issues.

3 participants