OCPBUGS-98159: Fix leading whitespace in Quick Start {{execute}} code snippets#16778
OCPBUGS-98159: Fix leading whitespace in Quick Start {{execute}} code snippets#16778dtambat wants to merge 1 commit into
Conversation
… snippets
The generated <pre><code> markup for {{execute}} code blocks had a
newline and indentation between the <pre> and <code> tags. Since <pre>
preserves whitespace literally, this rendered as a visible leading
blank line/indentation in Quick Start code snippets. Remove the
interstitial whitespace so <pre> and <code> are adjacent, matching
PatternFly's own {{copy}} template, and add regression tests.
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@dtambat: This pull request references Jira Issue OCPBUGS-98159, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
WalkthroughChangesExecute extension rendering
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dtambat The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @dtambat. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Analysis / Root cause:
The
{{execute}}markdown extensions (multiline-execute-extension.tsandinline-execute-extension.ts) generate a PatternFlyCodeBlockHTML string for Quick Start code snippets. The<pre>and<code>tags in that generated markup were on separate lines with indentation between them. Since<pre>useswhite-space: pre-wrap(PatternFly's owncode-block.cssrule, which preserves whitespace literally likewhite-space: pre), the newline and indentation between<pre>and<code>rendered as a visible leading blank line and leading spaces in the snippet, even though the snippet text itself (group.trim()) was already trimmed. This reproduces on any Quick Start with an{{execute}}code snippet (e.g. "Enable Developer Perspective"), on fresh 4.19/4.21 installs and after upgrades.PatternFly's own
{{copy}}extension avoids this by keeping<pre><code>...</code></pre>adjacent on one line, which this fix now mirrors.Solution description:
<pre>and<code>opening tags (and their closing tags) in bothmultiline-execute-extension.tsandinline-execute-extension.ts, so the tags are directly adjacent in the generated HTML.execute-extensions.spec.ts) asserting the generated HTML for both extensions has<pre>/<code>adjacent with no interstitial whitespace text node, and that the rendered<code>element's text content has no leading whitespace.innerTextfrom the<code data-snippet-id>element directly, so they were unaffected by this purely visual bug.Screenshots / screen recording:
Verified using the real
{{execute}}snippet from theenable-developer-perspectiveConsoleQuickStart on a live OCP 4.21.17 test cluster (the same Quick Start named in the bug's repro steps), rendered against the actual PatternFly 6.6.0CodeBlockCSS:code.innerText(what Copy to clipboard / Run in Web Terminal actually read) is identical before and after, confirming those behaviors are unaffected by this purely visual fix:Test setup:
Open the Quick Starts catalog (Help icon (?) → Quick Starts) and select any Quick Start containing an
{{execute}}code snippet, e.g. "Enable Developer Perspective".Test cases:
{{execute}}code snippet (inline and/or multiline) and confirm there is no leading blank line or leading spaces before the snippet text. (Verified above using real cluster content, pre/post fix comparison.)code.innerTextidentical before/after fix.)innerTextvalue used by both features.)Browser conformance:
(Verification above used headless Chrome against real cluster content; full manual QA in each browser against a running Console build is still recommended before merge.)
Additional info:
Jira: https://redhat.atlassian.net/browse/OCPBUGS-98159
Reviewers and assignees: