-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: refocus element after a diff #4244
Conversation
📊 Tachometer Benchmark ResultsSummaryduration
usedJSHeapSize
Results02_replace1k
duration
usedJSHeapSize
run-warmup-0
run-warmup-1
run-warmup-2
run-warmup-3
run-warmup-4
run-final
03_update10th1k_x16
duration
usedJSHeapSize
07_create10k
duration
usedJSHeapSize
filter_list
duration
usedJSHeapSize
hydrate1k
duration
usedJSHeapSize
many_updates
duration
usedJSHeapSize
text_update
duration
usedJSHeapSize
todo
duration
usedJSHeapSize
|
Size Change: +323 B (+0.52%) Total Size: 62.5 kB
ℹ️ View Unchanged
|
perf impact here is not worthwhile IMO, since it impacts performance on every diff regardless of whether focus needed to be restored. I'd love to come up with a way to have the diff avoid losing focus in this case, but the problem I see is that it would always be specific to focus state. It would never fix things like Here's a particularly fun case where, no matter what we do, at least one of the iframes will be reloaded: function Swapper() {
const [swapped, swap] = useReducer(s => !s, false);
const a = <iframe key="a" src="/a.html" />;
const b = <iframe key="b" src="/b.html" />;
return <>
<button onClick={swap}>Swap</button>
{swapped ? [b, a] : [a, b]}
</>;
} |
📊 Tachometer Benchmark ResultsSummaryduration
usedJSHeapSize
Resultscreate10kduration
usedJSHeapSize
filter-listduration
usedJSHeapSize
hydrate1kduration
usedJSHeapSize
many-updatesduration
usedJSHeapSize
replace1kduration
usedJSHeapSize
run-warmup-0
run-warmup-1
run-warmup-2
run-warmup-3
run-warmup-4
run-final
text-updateduration
usedJSHeapSize
tododuration
usedJSHeapSize
update10th1kduration
usedJSHeapSize
|
This could be perf neutral but there are a lot of considerations like in-render blurring as well as cross-frame focus 😅 just wanted to check the perf and size after these changes |
This adds back the focussing of elements, this now only happens after committing the root rather than performing this check on every phase of
child-diffing
. This PR mainly checks whether it's worth the byte-size and to start a discussionFixes #4235
Fixes #3242