Skip to content

Commit 7251cf4

Browse files
committed
fixes #376 - reset response state in focused mode
1 parent 0e7ffa3 commit 7251cf4

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/components/api-request.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,11 @@ export default class ApiRequest extends LitElement {
386386
</div>`;
387387
}
388388

389+
resetRequestBodySelection() {
390+
this.selectedRequestBodyType = '';
391+
this.selectedRequestBodyExample = '';
392+
}
393+
389394
// Request-Body Event Handlers
390395
onSelectExample(e) {
391396
this.selectedRequestBodyExample = e.target.value;
@@ -410,11 +415,6 @@ export default class ApiRequest extends LitElement {
410415
}, 0, mimeDropdownEl);
411416
}
412417

413-
resetRequestBodySelection() {
414-
this.selectedRequestBodyType = '';
415-
this.selectedRequestBodyExample = '';
416-
}
417-
418418
requestBodyTemplate() {
419419
if (!this.request_body) {
420420
return '';

src/components/api-response.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default class ApiResponse extends LitElement {
2929
schemaStyle: { type: String, attribute: 'schema-style' },
3030
renderStyle: { type: String, attribute: 'render-style' },
3131
selectedStatus: { type: String, attribute: 'selected-status' },
32-
selectedMimeType: { type: String },
32+
selectedMimeType: { type: String, attribute: 'selected-mime-type' },
3333
activeSchemaTab: { type: String, attribute: 'active-schema-tab' },
3434
schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
3535
schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
@@ -89,6 +89,11 @@ export default class ApiResponse extends LitElement {
8989
`;
9090
}
9191

92+
resetSelection() {
93+
this.selectedStatus = '';
94+
this.selectedMimeType = '';
95+
}
96+
9297
/* eslint-disable indent */
9398
responseTemplate() {
9499
if (!this.responses) { return ''; }

src/rapidoc.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,16 @@ export default class RapiDoc extends LitElement {
709709
// Disable IntersectionObserver before scrolling into the view, else it will try to scroll the navbar which is not needed here
710710
this.isIntersectionObserverActive = false;
711711

712-
// for focused style it is important to reset request-body-selection which maintains the state for in case of multiple body
712+
// for focused style it is important to reset request-body-selection and response selection which maintains the state for in case of multiple req-body or multiple response mime-type
713713
if (this.renderStyle === 'focused') {
714714
const requestEl = this.shadowRoot.querySelector('api-request');
715715
if (requestEl) {
716716
requestEl.resetRequestBodySelection();
717717
}
718+
const responseEl = this.shadowRoot.querySelector('api-response');
719+
if (responseEl) {
720+
responseEl.resetSelection();
721+
}
718722
}
719723
contentEl.scrollIntoView({ behavior: 'auto', block: 'start' });
720724
const oldNavEl = this.shadowRoot.querySelector('.nav-bar-tag.active, .nav-bar-path.active, .nav-bar-info.active, .nav-bar-h1.active, .nav-bar-h2.active');

0 commit comments

Comments
 (0)