Skip to content

fix(root): resize expanded code previews - #1887

Open
sylvesterkaczmarek wants to merge 7 commits into
mi6:developfrom
sylvesterkaczmarek:fix/1845-code-preview-height
Open

sylvesterkaczmarek wants to merge 7 commits into
mi6:developfrom
sylvesterkaczmarek:fix/1845-code-preview-height

Conversation

@sylvesterkaczmarek

@sylvesterkaczmarek sylvesterkaczmarek commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix code preview height recalculation when users toggle Show full code and Show less code.

Problem

The code preview panels share an explicit synchronized height. After expanding a preview, reading scrollHeight while that larger fixed height is still applied can preserve the expanded height when the preview is collapsed again.

Fix

Temporarily reset both panel heights to auto before measuring their natural scrollHeight, then restore the synchronized height using the fresh measurement. This preserves equal-height framework tabs while allowing both expansion and collapse to resize correctly.

Verification

On the Date Picker code page, the first preview measures 58 px initially, expands to 666 px, and returns to 58 px after Show less code. Prettier, TypeScript, ESLint, Jest, and the full production build pass locally.

Closes #1845

@GCHQ-Developer-530

Copy link
Copy Markdown
Contributor

Please can you rebase this pull request?

@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the fix/1845-code-preview-height branch from 2d243f8 to 37976be Compare August 21, 2026 20:08
@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest develop. Thanks!

@GCHQ-Developer-299 GCHQ-Developer-299 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.

When tested locally the change works, however when you minimise the code preview it does not return to the correct size:

Screen.Recording.2026-08-27.at.11.44.17.mov

However, this change does seem to remedy #1844 (i've not had the Code Previews fail to appear while testing these changes)

@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the fix/1845-code-preview-height branch from 37976be to ce6fad2 Compare September 15, 2026 11:18
@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor Author

Thanks for catching the collapse case. I’ve rebased this onto the current develop and updated the height calculation so the panels are measured at their natural height before the shared height is reapplied. On the Date Picker example I verified 58 px → 666 px → 58 px across compact, full, and compact states. Prettier, TypeScript, ESLint, Jest, and the full production build all pass locally. Thanks again.

This branch has not been deployed

No deployments
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.

3 participants