Repository navigation
Conversation
A JSON-only example hides the control when it lives in the scenario panel. An example with one language must not render an empty selector. Co-Authored-By: Grok 4.7 <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Render the shared multi-language samples above the scenario panels so the switch hides the request example, not the language control. Co-Authored-By: Grok 4.7 <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Requesting changes due to a blocking initial-render mismatch between the selected scenario and the shared command samples.
What is this? | From workflow: PR Review
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
| @if (shared is not null) | ||
| { | ||
| var sharedOptions = Model.Scenarios | ||
| .Select(choice => new ApiSelectOption(choice.Title, choice.TabId, choice.TabId == Model.Scenarios[0].TabId)) |
There was a problem hiding this comment.
[HIGH] Initial selected example can disagree with the shared code samples
When shared resolves to a scenario that is not Model.Scenarios[0], the top shared code-sample card renders shared.CodeSamples but the scenario select is initialized to the first scenario (choice.TabId == Model.Scenarios[0].TabId). That creates an inconsistent initial state where the UI indicates one example is selected while showing command samples for a different example.
A concrete failure case is an operation where only the second scenario is multi-language and FindScenarioForCodeSamples maps code samples to that second scenario.
Please initialize the selected option (and initial visible scenario panel) from shared.TabId when shared samples are rendered, so scenario selection and displayed command samples stay aligned.
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4278/ |
Assembler preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/docs/4278/api/doc/elasticsearch-serverless/operation/operation-inference-put-amazonbedrock
Choosing another API example keeps the language control on screen and leaves the selected language unchanged. An example with only one language does not show an empty language control.
Affects: API reference, Site UI
Prompt summary: Keep the language selector on screen after a different example is chosen, and keep the previously selected language. An example that exists in only one language must not show a broken empty selector. Fix this against the example switch on main. Do not rebuild the examples list from docs-builder#4269.
Why
The language control is rendered inside the scenario panel. Choosing another example hides that panel, so the control leaves the screen. This shows up on operations such as the one in elastic/docs-eng-team#891, where Console and curl belong to one example and the other examples are request JSON only. An empty language control on those JSON examples would leave the page with a selector that has nothing to select.
Closes elastic/docs-eng-team#891
What
Language control
The shared Console and curl samples render once above the example panels. Choosing another example hides that example's request body. The language control stays on screen, and the selected language stays selected.
Request example
The chosen example's request JSON stays in the panel under a Request example heading.
One language
An example that has only one language does not render a language control. The request body still shows, and the example dropdown still switches examples.
Verify
dotnet build tests/Elastic.ApiExplorer.Tests dotnet .artifacts/bin/Elastic.ApiExplorer.Tests/debug/Elastic.ApiExplorer.Tests.dll --treenode-filter "/*/*/OperationExamplesPanelRenderingTests/*"Out of scope: Listing every example in the rail stays on docs-builder#4269. Heading markup and heading CSS are unchanged.
Made with Cursor