Skip to content

Commit

Permalink
fix: collapse expanded header in which content is present in json form
Browse files Browse the repository at this point in the history
  • Loading branch information
srijitcoder committed Nov 5, 2024
1 parent 98f581b commit d2ec432
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/methods/file-edit-view/init-eox-jsonform.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ export function initEOXJSONFormMethod(jsonFormInstance, isFormJSON) {
const shadowRoot = getShadowRoot(jsonFormInstance);
const style = document.createElement("style");

setTimeout(() => {
const expandButtons = [
...shadowRoot.querySelectorAll(
".row:not([style*='display: none']) .je-header .json-editor-btn-collapse.json-editor-btntype-toggle span",
),
].filter((span) => span.innerText === "Expand");

expandButtons.forEach((expandButtonEle) => {
const thirdParentEle =
expandButtonEle?.parentElement?.parentElement?.parentElement;

if (thirdParentEle) {
const displayNoneItems = thirdParentEle.querySelectorAll(
'.je-indented-panel[style*="display: none"]',
);

if (displayNoneItems.length) expandButtonEle.click();
}
});
}, 500);

style.textContent = `
.je-indented-panel .row {
margin-top: 10px;
Expand Down

0 comments on commit d2ec432

Please sign in to comment.