Skip to content

Commit 197b8c5

Browse files
fix: Safari rendering issues with code preview when switching tabs or scrolling (#489)
1 parent 950ee46 commit 197b8c5

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/ui/src/solidity/App.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { createEventDispatcher } from 'svelte';
2+
import { createEventDispatcher, tick } from 'svelte';
33
44
import hljs from './highlightjs';
55
@@ -37,11 +37,18 @@
3737
3838
const dispatch = createEventDispatcher();
3939
40+
async function allowRendering() {
41+
showCode = false;
42+
await tick();
43+
showCode = true;
44+
}
45+
4046
export let initialTab: string | undefined = 'ERC20';
4147
4248
export let tab: Kind = sanitizeKind(initialTab);
4349
$: {
4450
tab = sanitizeKind(tab);
51+
allowRendering();
4552
dispatch('tab-change', tab);
4653
};
4754
@@ -55,6 +62,8 @@
5562
5663
let contract: Contract = new ContractBuilder(initialOpts.name ?? 'MyToken');
5764
65+
let showCode = true;
66+
5867
$: functionCall && applyFunctionCall()
5968
6069
$: opts = allOpts[tab];
@@ -87,6 +96,7 @@
8796
throw e;
8897
}
8998
}
99+
allowRendering();
90100
}
91101
}
92102
@@ -441,7 +451,9 @@
441451
</div>
442452
{/if}
443453
<pre class="flex flex-col grow basis-0 overflow-auto">
454+
{#if showCode}
444455
<code class="hljs -solidity grow overflow-auto p-4 {hasErrors ? 'no-select' : ''}">{@html highlightedCode}</code>
456+
{/if}
445457
</pre>
446458
<DefenderDeployModal isOpen={showDeployModal} />
447459
</div>

0 commit comments

Comments
 (0)