-
Notifications
You must be signed in to change notification settings - Fork 863
fix(EuiCodeBlock): fixes re-renders causing blank lines to appear when using isVirtualized if scrolled #9196
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(EuiCodeBlock): fixes re-renders causing blank lines to appear when using isVirtualized if scrolled #9196
Conversation
|
💚 CLA has been signed |
|
👋 Since this is a community submitted pull request, a Buildkite build has not been started automatically. Would an Elastic organization member please verify the contents of this pull request and kick off a build manually? |
5d1a2a8 to
0000557
Compare
mgadewoll
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sravanth-space Thanks for digging into this bug! It's awesome that you found the root cause for the issue 🎉
There are some adjustments we'll need to make here to ensure the component remains accessible.
| ); | ||
|
|
||
| // Render the accessibility label outside the virtualized container | ||
| // This preserves accessibility while fixing virtualization bugs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This preserves accessibility while fixing virtualization bugs
This is unfortunately not true.
While the element is in the DOM and navigable by screen reader browse mode, moving the label out of the pre breaks accessibility when focusing the element as the label now is not read.
ℹ️ Why was it added as child in the first place?
The main limitation here is that pre does not support aria-label or aria-labelledby, so we can't keep the label outside of the element. To ensure its read out together it has to be content of the focusable element.
| expected (production state) | unexpected (current PR state) |
|---|---|
Screen.Recording.2025-11-13.at.13.45.17.mov |
Screen.Recording.2025-11-13.at.13.44.38.mov |
Thanks so much for the thorough review and for catching the accessibility issues! 🙏 |
|
@sravanth-space Please be so kind to also update the PR description according to the final updates 🙏 |
|
@sravanth-space I added a VRT-only story as regression test for this bug, I hope you don't mind me pushing it directly. |
Thanks. I have updated the PR description and for the jest and cypress tests I haven't added/updated please let me know if I need to add/update any. |
mgadewoll
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 The changes are LGTM and the fix works correctly. Awesome work!
Thanks for contributing! 🎉
|
buildkite test this |
- Fixes blank rendering in virtualized CodeBlock when scrolled (elastic#9034) - Moves labels outside <pre> in both virtualized and regular variants - Preserves accessibility while preventing react-window calculation issues - Ensures consistent architecture across all CodeBlock rendering modes Partially reverts the implementation approach from PR elastic#8887 while maintaining the accessibility improvements.
renamed with the PR number instead of issue number.
…ibility Addresses review feedback by placing the label in VirtualizedInnerElement instead of outside the <pre> tag, preserving screen reader support while fixing react-window scroll calculations. Reverts the changes in code_block.tsx Also updated the changelog to include the bug number.
remove virtualizedList Updated the comments
- adds the pre-fix state as history
912a330 to
2d429f9
Compare
|
@sravanth-space What was the force-push for? Did you rebase or add any changes? |
|
buildkite test this |
Sorry I have rebased without any changes.😅 |
ℹ️ @sravanth-space Just fyi, we don't have to rebase right away if the PR says |
💚 Build SucceededHistory
|
💚 Build Succeeded
History
|
Summary
isVirtualizedif scrolled #9034)Partially reverts the implementation approach from PR #8887 while maintaining the accessibility improvements.
Why are we making this change?
Problem:
After PR #8887, the accessibility label was injected inside the <pre> element managed by react-window's virtualization as part of the VirtualizedOuterElement. This caused react-window to miscalculate scroll offsets, resulting in blank lines appearing when:
Root Cause:
react-window's FixedSizeList requires the outer element to be "pure" - any injected content disrupts its internal measurements and scroll position calculations.
Solution:
VirtualizedOuterElementtoVirtualizedInnerElementto ensure a stable container for the virtualized calculationspreelement and hence is read as label when the code element is focusedScreenshots #
Its best to use the sandbox mentioned in the issue https://codesandbox.io/p/devbox/euicodeblock-virtualized-within-euiflyout-height-100-forked-6j2tlc?workspaceId=ws_PBRiDLztB2gZ9hEEoiqpdS and change it with this pr patch.
Impact to users
Fixes a bug where virtualized code blocks would show blank lines when scrolled or when content updates. No breaking changes.
🟢 There are no updates required on consumers side.
QA
Remove or strikethrough items that do not apply to your PR.
General checklist
Added or updated jest and cypress tests