Skip to content

Commit 17fc047

Browse files
committed
fix(initial-load): prevent FOUC on initial load
1 parent 129339d commit 17fc047

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ <h1>JSONLab</h1>
5353
<i data-lucide="moon" id="theme-icon"></i>
5454
</button>
5555
</div>
56+
<script>
57+
// prevent FOUC: activate the correct mode button before first paint
58+
(function () {
59+
var mode = localStorage.getItem('jsonlab_global_view_mode') || 'normal';
60+
if (mode !== 'normal') {
61+
document.getElementById('btn-mode-normal').classList.remove('active');
62+
var btn = document.getElementById('btn-mode-' + mode);
63+
if (btn) btn.classList.add('active');
64+
}
65+
})();
66+
</script>
5667
</header>
5768

5869
<!-- Main Editor Area -->

src/js/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const App = {
5151
rightContainer.className = 'editor-wrapper';
5252
rightContainer.id = 'editor-wrapper-right';
5353
rightContainer.style.flex = '1';
54-
rightContainer.style.display = 'flex';
54+
rightContainer.style.display = 'none'; // hidden until switchGlobalMode sets the correct layout
5555
rightContainer.style.flexDirection = 'column';
5656
rightContainer.style.minWidth = '0';
5757
container.appendChild(rightContainer);

0 commit comments

Comments
 (0)