fix: eliminate UX flash by calling setStrings() immediately in observer
The 100ms pure-debounce approach caused a visible layout flash on every render (normal mode too) because Tokyo UX was not applied for 100ms. Fix: call setStrings() immediately in the MutationObserver callback to prevent any flash, AND keep a 250ms delayed follow-up call to catch async train re-renders from mock XHR setTimeout(0) responses. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1258,10 +1258,12 @@ const textInsert = new MutationObserver( (mutations) =>{
|
||||
const currentLines = document.querySelector('#topHeader div').innerText;
|
||||
window.ReactNativeWebView.postMessage(JSON.stringify({type:"currentLines",currentLines}));
|
||||
}
|
||||
// Debounced setStrings: fires after any subtree change settles.
|
||||
// This catches async train re-renders (e.g. from mock XHR setTimeout(0)).
|
||||
// Apply Tokyo UX immediately (prevents visible flash on normal renders).
|
||||
try { setStrings(); } catch(e) {}
|
||||
// Also schedule a follow-up after 250ms to catch async re-renders
|
||||
// triggered by mock XHR setTimeout(0) responses that settle later.
|
||||
clearTimeout(_ssDebounce);
|
||||
_ssDebounce = setTimeout(() => { try { setStrings(); } catch(e) {} }, 100);
|
||||
_ssDebounce = setTimeout(() => { try { setStrings(); } catch(e) {} }, 250);
|
||||
});
|
||||
|
||||
// 監視を開始 (subtree: true で深い子孫の変化も捕捉する)
|
||||
|
||||
Reference in New Issue
Block a user