Skip to content

Commit eff6e20

Browse files
authored
Merge pull request #278 from ahamelers/release/2.2
Fix unselectable request body
2 parents 3d21e4e + 8cdee24 commit eff6e20

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

src/components/api-request.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export default class ApiRequest extends LitElement {
387387
this.selectedRequestBodyExample = e.target.value;
388388
const exampleDropdownEl = e.target;
389389
window.setTimeout((selectEl) => {
390-
const exampleTextareaEl = selectEl.closest('.example-panel').querySelector('.request-body-param');
390+
const exampleTextareaEl = selectEl.closest('.example-panel').querySelector(`.request-body-param[data-example="${this.selectedRequestBodyExample}"`);
391391
const userInputExampleTextareaEl = selectEl.closest('.example-panel').querySelector('.request-body-param-user-input');
392392
userInputExampleTextareaEl.value = exampleTextareaEl.value;
393393
this.computeCurlSyntax();
@@ -505,19 +505,20 @@ export default class ApiRequest extends LitElement {
505505
.value="${this.fillRequestWithDefault === 'true' ? (displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8)) : ''}"
506506
></textarea>
507507
</slot>
508-
509-
<!-- This textarea(hidden) is to store the original example value, this will remain unchanged when users switches from one example to another, its is used to populate the editable textarea -->
510-
<textarea
511-
class = "textarea is-hidden request-body-param ${reqBody.mimeType.substring(reqBody.mimeType.indexOf('/') + 1)}"
512-
spellcheck = "false"
513-
data-ptype = "${reqBody.mimeType}"
514-
style="width:100%; resize:vertical; display:none"
515-
.value="${(displayedBodyExample.exampleFormat === 'text' ? displayedBodyExample.exampleValue : JSON.stringify(displayedBodyExample.exampleValue, null, 8))}"
516-
></textarea>
517508
</div>`
518509
: ''}
519-
520-
</div>
510+
${reqBodyExamples.map((bodyExample) => html`
511+
<!-- This textarea(hidden) is to store the original example value, this will remain unchanged when users switches from one example to another, its is used to populate the editable textarea -->
512+
<textarea
513+
class = "textarea is-hidden request-body-param ${reqBody.mimeType.substring(reqBody.mimeType.indexOf('/') + 1)}"
514+
spellcheck = "false"
515+
data-ptype = "${reqBody.mimeType}"
516+
data-example = "${bodyExample.exampleId}"
517+
style="width:100%; resize:vertical; display:none"
518+
.value="${(bodyExample.exampleFormat === 'text' ? bodyExample.exampleValue : JSON.stringify(bodyExample.exampleValue, null, 8))}"
519+
></textarea>
520+
`)}
521+
</div>
521522
`;
522523
} else if (this.selectedRequestBodyType.includes('form-urlencoded') || this.selectedRequestBodyType.includes('form-data')) {
523524
bodyTabNameUseBody = false;

0 commit comments

Comments
 (0)