fix(alpine): resolve console errors on editor and agent panel
Initialize coverOpen/coverLoading in editorState, render import file info with x-if instead of x-show (null deref), split x-if/x-for on the agent mention menu, guard m.steps.length and use unique keys for the icon picker. Also reduce htmx swap responses to .main-wrapper so shell scripts (agent panel, base inline) are not re-executed on partial navigation.
This commit is contained in:
@@ -366,6 +366,22 @@
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
// htmx parses the WHOLE response and executes every <script> it contains,
|
||||
// including shell scripts (agent panel, base inline scripts) that live
|
||||
// outside .main-wrapper. Re-running those corrupts Alpine state (x-for
|
||||
// teardown errors). Before the swap, reduce the response to the
|
||||
// .main-wrapper fragment so only page scripts are executed.
|
||||
document.body.addEventListener('htmx:beforeSwap', function(evt) {
|
||||
var d = evt.detail;
|
||||
if (!d || !d.target || !d.target.classList || !d.target.classList.contains('main-wrapper')) return;
|
||||
if (!d.serverResponse || typeof d.serverResponse !== 'string') return;
|
||||
try {
|
||||
var doc = new DOMParser().parseFromString(d.serverResponse, 'text/html');
|
||||
var mw = doc.querySelector('.main-wrapper');
|
||||
if (mw) d.serverResponse = mw.outerHTML;
|
||||
} catch (e) { /* keep original response on parse failure */ }
|
||||
});
|
||||
|
||||
document.body.addEventListener('htmx:afterSwap', function(evt) {
|
||||
syncAfterSwap(evt.detail && evt.detail.xhr);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user