From 54fd987b31fe6ac5dfe274da25615761c4199855 Mon Sep 17 00:00:00 2001 From: ShikhaSaboo Date: Wed, 25 Jun 2025 15:24:43 +0530 Subject: [PATCH 1/2] fix: fix opened model schema resolving issue on spec change --- src/core/plugins/oas31/components/models/models.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/core/plugins/oas31/components/models/models.jsx b/src/core/plugins/oas31/components/models/models.jsx index 86b8bf57bf3..e8092287f9c 100644 --- a/src/core/plugins/oas31/components/models/models.jsx +++ b/src/core/plugins/oas31/components/models/models.jsx @@ -30,7 +30,11 @@ const Models = ({ * Effects. */ useEffect(() => { - const isOpenAndExpanded = isOpen && defaultModelsExpandDepth > 1 + const hasAtLeastOneSchemaExpanded = Object.entries(schemas).some( + ([schemaName]) => layoutSelectors.isShown([...schemasPath, schemaName], false) + ) + const isOpenAndExpanded = + isOpen && (defaultModelsExpandDepth > 1 || hasAtLeastOneSchemaExpanded) const isResolved = specSelectors.specResolvedSubtree(schemasPath) != null if (isOpenAndExpanded && !isResolved) { specActions.requestResolvedSubtree(schemasPath) @@ -55,12 +59,16 @@ const Models = ({ } } const handleJSONSchema202012Expand = (schemaName) => (e, expanded) => { + const schemaPath = [...schemasPath, schemaName] if (expanded) { - const schemaPath = [...schemasPath, schemaName] const isResolved = specSelectors.specResolvedSubtree(schemaPath) != null if (!isResolved) { specActions.requestResolvedSubtree([...schemasPath, schemaName]) } + layoutActions.show(schemaPath, true) + } + else { + layoutActions.show(schemaPath, false) } } From 31f9f497329aa1da828817e490b20e42cab53964 Mon Sep 17 00:00:00 2001 From: ShikhaSaboo Date: Thu, 26 Jun 2025 11:31:45 +0530 Subject: [PATCH 2/2] chore: resolve eslint error --- src/core/plugins/oas31/components/models/models.jsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/plugins/oas31/components/models/models.jsx b/src/core/plugins/oas31/components/models/models.jsx index e8092287f9c..54e9d2b211a 100644 --- a/src/core/plugins/oas31/components/models/models.jsx +++ b/src/core/plugins/oas31/components/models/models.jsx @@ -30,11 +30,12 @@ const Models = ({ * Effects. */ useEffect(() => { - const hasAtLeastOneSchemaExpanded = Object.entries(schemas).some( - ([schemaName]) => layoutSelectors.isShown([...schemasPath, schemaName], false) + const includesExpandedSchema = Object.entries(schemas).some( + ([schemaName]) => + layoutSelectors.isShown([...schemasPath, schemaName], false) ) const isOpenAndExpanded = - isOpen && (defaultModelsExpandDepth > 1 || hasAtLeastOneSchemaExpanded) + isOpen && (defaultModelsExpandDepth > 1 || includesExpandedSchema) const isResolved = specSelectors.specResolvedSubtree(schemasPath) != null if (isOpenAndExpanded && !isResolved) { specActions.requestResolvedSubtree(schemasPath) @@ -65,9 +66,8 @@ const Models = ({ if (!isResolved) { specActions.requestResolvedSubtree([...schemasPath, schemaName]) } - layoutActions.show(schemaPath, true) - } - else { + layoutActions.show(schemaPath, true) + } else { layoutActions.show(schemaPath, false) } }