Skip to content

Commit b7b82f9

Browse files
committed
Cleanup the ACE editor before loading another resource details
Signed-off-by: tdruez <[email protected]>
1 parent be72ae2 commit b7b82f9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

scanpipe/templates/scanpipe/resource_detail.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
{{ detected_values|json_script:"detected_values" }}
2626
<script>
2727
{
28+
document.addEventListener('htmx:beforeSwap', function(evt) {
29+
// Clean up editor before HTMX swaps content
30+
if (window.editor) {
31+
window.editor.destroy();
32+
window.editor.container.remove();
33+
window.editor = null;
34+
}
35+
});
36+
2837
let editor = ace.edit("editor", {
2938
mode: "ace/mode/text",
3039
autoScrollEditorIntoView: true,
@@ -38,6 +47,9 @@
3847
fontFamily: "SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace",
3948
});
4049

50+
// Store globally for cleanup
51+
window.editor = editor;
52+
4153
function removeAllMarkers() {
4254
let session = editor.getSession();
4355
let markers = session.getMarkers();

scanpipe/templates/scanpipe/tree/resource_path_breadcrumb.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
{% endfor %}
2424
</ul>
2525
{% if path_segments %}
26-
<button class="button is-white copy-to-clipboard ml-1 p-2" aria-label="Copy path" data-copy="{{ path }}" data-copy-feedback="Path copied!">
26+
<button class="button is-white copy-to-clipboard p-2" aria-label="Copy path" data-copy="{{ path }}" data-copy-feedback="Path copied!">
2727
<i class="fa-regular fa-clone"></i>
2828
</button>
2929
{% endif %}

0 commit comments

Comments
 (0)